32#include <proto/exec.h>
33#include <proto/icon.h>
35#include <datatypes/pictureclass.h>
37#include <graphics/blitattr.h>
39#include <workbench/icon.h>
57#define THUMBNAIL_WIDTH 100
58#define THUMBNAIL_HEIGHT 86
61 ULONG trans, ULONG pals1,
struct ColorRegister *pal1,
int alpha);
65typedef struct amiga_icon_content {
74 bool quirks,
struct content **c);
75static bool amiga_icon_convert(
struct content *c);
76static void amiga_icon_destroy(
struct content *c);
77static bool amiga_icon_redraw(
struct content *c,
84static void *amiga_icon_get_internal(
const struct content *c,
void *context)
86 amiga_icon_content *icon_c = (amiga_icon_content *)c;
88 return icon_c->bitmap;
91static bool amiga_icon_is_opaque(
struct content *c)
93 amiga_icon_content *icon_c = (amiga_icon_content *)c;
95 if (icon_c->bitmap != NULL) {
103 .
create = amiga_icon_create,
104 .data_complete = amiga_icon_convert,
105 .destroy = amiga_icon_destroy,
106 .redraw = amiga_icon_redraw,
107 .clone = amiga_icon_clone,
108 .get_internal = amiga_icon_get_internal,
109 .type = amiga_icon_content_type,
110 .is_opaque = amiga_icon_is_opaque,
114static const char *amiga_icon_types[] = {
119 amiga_icon_content_handler)
124 bool quirks,
struct content **c)
126 amiga_icon_content *ai_content;
129 ai_content = calloc(1,
sizeof(amiga_icon_content));
130 if (ai_content == NULL)
133 error =
content__init(&ai_content->base, handler, imime_type, params,
134 llcache, fallback_charset, quirks);
140 *c = (
struct content *)ai_content;
151bool amiga_icon_convert(
struct content *c)
153 amiga_icon_content *icon_c = (amiga_icon_content *)c;
155 struct DiskObject *dobj;
157 unsigned char *imagebufptr = NULL;
163 char *filename = NULL;
166 struct ColorRegister *pal1;
178 p = strstr(filename,
".info");
181 dobj = GetIconTagList(filename, NULL);
193 ICONCTRLA_GetWidth,&
width,
194 ICONCTRLA_GetHeight,&
height,
200 if(dobj) FreeDiskObject(dobj);
205 if (!icon_c->bitmap) {
209 if(dobj) FreeDiskObject(dobj);
217 if(dobj) FreeDiskObject(dobj);
222 ICONCTRLA_GetImageData1, &imagebufptr,
227 IconControl(dobj, ICONCTRLA_GetTransparentColor1, &trans,
228 ICONCTRLA_GetPalette1, &pal1,
229 ICONCTRLA_GetPaletteSize1, &pals1,
240 for (offset = 0; offset < size; offset += 4) {
241 b = imagebufptr[offset+3];
242 g = imagebufptr[offset+2];
243 r = imagebufptr[offset+1];
244 a = imagebufptr[offset];
246 *imagebuf = r << 24 | g << 16 | b << 8 | a;
258 if(dobj) FreeDiskObject(dobj);
271void amiga_icon_destroy(
struct content *c)
273 amiga_icon_content *icon_c = (amiga_icon_content *)c;
275 if (icon_c->bitmap != NULL)
284bool amiga_icon_redraw(
struct content *c,
288 amiga_icon_content *icon_c = (amiga_icon_content *)c;
309 amiga_icon_content *ai;
312 ai = calloc(1,
sizeof(amiga_icon_content));
325 if (amiga_icon_convert(&ai->base) ==
false) {
344 ULONG trans, ULONG pals1,
struct ColorRegister *pal1,
int alpha)
347 struct ColorRegister *
colour;
348 struct ColorMap *cmap;
352 if (alpha==0) alpha=0xff;
355 if (!argbicon)
return(NULL);
357 cmap=GetColorMap(pals1);
365 colour = &pal1[icondata[i]];
367 if(icondata[i] == trans)
380 argbicon[i] = (a << 24) +
392 struct BitMap *bm = NULL;
393 ULONG *icondata1, *icondata2;
397 if(dobj == NULL)
return;
401 ICONCTRLA_GetImageData1,&icondata1,
402 ICONCTRLA_GetImageData2,&icondata2,
403 ICONCTRLA_GetWidth,&
width,
404 ICONCTRLA_GetHeight,&
height,
414 BltBitMapTags(BLITA_SrcX, 0,
416 BLITA_DestX,
width - 16,
421 BLITA_Dest, icondata1,
422 BLITA_SrcType, BLITT_BITMAP,
423 BLITA_DestType, BLITT_ARGB32,
424 BLITA_DestBytesPerRow,
width * 4,
428 BltBitMapTags(BLITA_SrcX, 0,
430 BLITA_DestX,
width - 16,
435 BLITA_Dest, icondata2,
436 BLITA_SrcType, BLITT_BITMAP,
437 BLITA_DestType, BLITT_ARGB32,
438 BLITA_DestBytesPerRow,
width * 4,
447 struct DiskObject *dobj = NULL;
448 ULONG *icondata1, *icondata2;
453 struct ColorRegister *pal1;
454 struct ColorRegister *pal2;
456 if(icon == NULL)
return;
460 dobj = GetIconTags(NULL,
461 ICONGETA_GetDefaultType, WBDRAWER,
466 dobj = GetIconTags(NULL, ICONGETA_GetDefaultName,
type,
467 ICONGETA_GetDefaultType, WBPROJECT,
471 if(dobj == NULL)
return;
475 ICONCTRLA_GetImageData1,&icondata1,
476 ICONCTRLA_GetImageData2,&icondata2,
477 ICONCTRLA_GetWidth,&
width,
478 ICONCTRLA_GetHeight,&
height,
484 IconControl(dobj, ICONCTRLA_GetTransparentColor1, &trans1,
485 ICONCTRLA_GetPalette1, &pal1,
486 ICONCTRLA_GetPaletteSize1, &pals1,
487 ICONCTRLA_GetTransparentColor2, &trans2,
488 ICONCTRLA_GetPalette2, &pal2,
489 ICONCTRLA_GetPaletteSize2, &pals2,
500 ICONCTRLA_SetImageData1, icondata1,
501 ICONCTRLA_SetImageData2, icondata2,
508 PutIconTags(
path, dobj,
509 ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE);
511 FreeDiskObject(dobj);
523 struct DiskObject *dobj;
538 BLITA_SrcType, BLITT_BITMAP,
540 BLITA_DestType, BLITT_ARGB32,
542 BLITA_Dest, icondata,
547 dobj = GetIconTags(NULL, ICONGETA_GetDefaultType, WBPROJECT,
548 ICONGETA_GetDefaultName,
"iconify",
557 ICONCTRLA_SetImageData1, icondata,
558 ICONCTRLA_SetImageData2, NULL,
562 dobj->do_Gadget.UserData = bm;
564 LayoutIconA(dobj, (
struct Screen *)~0UL, NULL);
571 struct bitmap *bm = dobj->do_Gadget.UserData;
573 FreeDiskObject(dobj);
Content handling interface.
void content_destroy(struct content *c)
Destroy and free a content.
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
void content_set_done(struct content *c)
Put a content in status CONTENT_STATUS_DONE.
nserror content__init(struct content *c, const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks)
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
nserror content__clone(const struct content *c, struct content *nc)
Clone a content's data members.
void content_set_ready(struct content *c)
Put a content in status CONTENT_STATUS_READY and unlock the content.
void content_set_status(struct content *c, const char *status_message)
Updates content with new status.
#define CONTENT_FACTORY_REGISTER_TYPES(HNAME, HTYPELIST, HHANDLER)
Protected interface to Content handling.
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
@ CONTENT_STATUS_DONE
Content has completed all processing.
content_type
The type of a content.
@ CONTENT_IMAGE
All images.
@ CONTENT_MSG_ERROR
error occurred
nserror
Enumeration of error codes.
@ NSERROR_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
void * amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
struct BitMap * ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, bool palette_mapped, struct BitMap *friendbm)
void ami_bitmap_free_icondata(struct bitmap *bm)
Free an icondata pointer.
void amiga_bitmap_modified(void *bitmap)
The bitmap image has changed, so flush any persistant cache.
void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
Set an icondata pointer.
unsigned char * amiga_bitmap_get_buffer(void *bitmap)
Return a pointer to the pixel data in a bitmap.
void amiga_bitmap_destroy(void *bitmap)
Free a bitmap.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
struct DiskObject * amiga_icon_from_bitmap(struct bitmap *bm)
void amiga_icon_free(struct DiskObject *dobj)
static ULONG * amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height, ULONG trans, ULONG pals1, struct ColorRegister *pal1, int alpha)
void amiga_icon_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type)
void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct DiskObject *dobj)
Content for image/x-amiga-icon (icon.library interface).
Generic bitmap handling interface.
Public content interface.
struct bitmap * content_get_bitmap(struct hlcache_handle *h)
Retrieve the bitmap contained in an image content.
Target independent plotting interface.
unsigned long bitmap_flags_t
static struct llcache_s * llcache
low level cache state
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
Minimal compatibility header for AmigaOS 3.
#define ICONCTRLA_GetImageDataFormat
#define ICONCTRLA_SetImageDataFormat
#define IDFMT_PALETTEMAPPED
#define BLITA_UseSrcAlpha
#define IDFMT_DIRECTMAPPED
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
Content operation function table.
nserror(* create)(const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
parameters to content redraw
int height
vertical dimension
bool repeat_y
whether content is tiled in y direction
bool repeat_x
whether content is tiled in x direction
int y
coordinate for top-left of redraw
int x
coordinate for top-left of redraw
colour background_colour
The background colour.
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
Content which corresponds to a single URL.
int height
Height dimension, if applicable.
int width
Width dimension, if applicable.
content_status status
Current status.
bool(* get_opaque)(void *bitmap)
Get the opacity of a bitmap.
Representation of an HTTP parameter.
Handle to low-level cache object.
struct gui_bitmap_table * bitmap
Bitmap table.
nserror(* bitmap)(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
const struct plotter_table * plot
Current plot operation table.
uint32_t colour
Colour type: XBGR.
Extra data for some content_msg messages.
nserror netsurf_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl.
Default operations table for files.
Interface to a number of general purpose functionality.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.