2010-10-31 14:14:26 +03:00
|
|
|
/*
|
2010-10-30 18:23:38 +04:00
|
|
|
* Copyright 2010 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Content for image/x-amiga-icon (icon.library implementation).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "utils/config.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2015-04-17 00:36:29 +03:00
|
|
|
#include <stdbool.h>
|
2010-10-30 18:23:38 +04:00
|
|
|
|
2010-10-31 14:14:26 +03:00
|
|
|
#include <proto/exec.h>
|
2010-10-30 18:23:38 +04:00
|
|
|
#include <proto/icon.h>
|
|
|
|
|
2010-10-31 14:14:26 +03:00
|
|
|
#include <datatypes/pictureclass.h>
|
2011-01-07 02:17:17 +03:00
|
|
|
#ifdef __amigaos4__
|
2010-10-31 14:14:26 +03:00
|
|
|
#include <graphics/blitattr.h>
|
2011-01-07 02:17:17 +03:00
|
|
|
#endif
|
2010-10-30 18:23:38 +04:00
|
|
|
#include <workbench/icon.h>
|
|
|
|
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
2014-05-27 03:08:04 +04:00
|
|
|
#include "utils/file.h"
|
2016-05-30 23:05:57 +03:00
|
|
|
#include "netsurf/plotters.h"
|
2016-05-27 01:01:03 +03:00
|
|
|
#include "netsurf/bitmap.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "netsurf/content.h"
|
2015-04-24 13:56:19 +03:00
|
|
|
#include "content/content_protected.h"
|
2010-10-30 18:23:38 +04:00
|
|
|
|
2015-04-17 00:36:29 +03:00
|
|
|
#include "amiga/os3support.h"
|
|
|
|
#include "amiga/bitmap.h"
|
|
|
|
#include "amiga/icon.h"
|
2016-11-19 18:50:22 +03:00
|
|
|
#include "amiga/memory.h"
|
2015-04-17 00:36:29 +03:00
|
|
|
|
2011-07-03 15:47:54 +04:00
|
|
|
#define THUMBNAIL_WIDTH 100 /* Icon sizes for thumbnails, usually the same as */
|
|
|
|
#define THUMBNAIL_HEIGHT 86 /* WIDTH/HEIGHT in desktop/thumbnail.c */
|
|
|
|
|
2016-06-02 02:44:20 +03:00
|
|
|
static ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height,
|
2010-10-31 14:14:26 +03:00
|
|
|
ULONG trans, ULONG pals1, struct ColorRegister *pal1, int alpha);
|
|
|
|
|
|
|
|
#ifdef WITH_AMIGA_ICON
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
typedef struct amiga_icon_content {
|
|
|
|
struct content base;
|
2011-08-31 16:12:41 +04:00
|
|
|
|
|
|
|
struct bitmap *bitmap; /**< Created NetSurf bitmap */
|
2011-05-07 00:40:09 +04:00
|
|
|
} amiga_icon_content;
|
|
|
|
|
|
|
|
static nserror amiga_icon_create(const content_handler *handler,
|
2016-04-19 01:17:38 +03:00
|
|
|
lwc_string *imime_type, const struct http_parameter *params,
|
2016-06-06 10:59:23 +03:00
|
|
|
struct llcache_handle *llcache, const char *fallback_charset,
|
2011-05-07 00:40:09 +04:00
|
|
|
bool quirks, struct content **c);
|
|
|
|
static bool amiga_icon_convert(struct content *c);
|
|
|
|
static void amiga_icon_destroy(struct content *c);
|
2011-06-29 12:33:28 +04:00
|
|
|
static bool amiga_icon_redraw(struct content *c,
|
2011-06-30 19:48:07 +04:00
|
|
|
struct content_redraw_data *data, const struct rect *clip,
|
|
|
|
const struct redraw_context *ctx);
|
2011-05-07 00:40:09 +04:00
|
|
|
static nserror amiga_icon_clone(const struct content *old,
|
|
|
|
struct content **newc);
|
2011-09-03 13:27:42 +04:00
|
|
|
static content_type amiga_icon_content_type(void);
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-08-31 16:12:41 +04:00
|
|
|
static void *amiga_icon_get_internal(const struct content *c, void *context)
|
|
|
|
{
|
|
|
|
amiga_icon_content *icon_c = (amiga_icon_content *)c;
|
|
|
|
|
|
|
|
return icon_c->bitmap;
|
|
|
|
}
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
static const content_handler amiga_icon_content_handler = {
|
2011-05-09 19:32:34 +04:00
|
|
|
.create = amiga_icon_create,
|
|
|
|
.data_complete = amiga_icon_convert,
|
|
|
|
.destroy = amiga_icon_destroy,
|
|
|
|
.redraw = amiga_icon_redraw,
|
|
|
|
.clone = amiga_icon_clone,
|
2011-08-31 16:12:41 +04:00
|
|
|
.get_internal = amiga_icon_get_internal,
|
2011-05-09 19:32:34 +04:00
|
|
|
.type = amiga_icon_content_type,
|
|
|
|
.no_share = false,
|
2011-05-07 00:40:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *amiga_icon_types[] = {
|
|
|
|
"image/x-amiga-icon"
|
|
|
|
};
|
|
|
|
|
2011-09-16 02:31:16 +04:00
|
|
|
CONTENT_FACTORY_REGISTER_TYPES(amiga_icon, amiga_icon_types,
|
|
|
|
amiga_icon_content_handler)
|
2011-05-07 00:40:09 +04:00
|
|
|
|
|
|
|
nserror amiga_icon_create(const content_handler *handler,
|
2016-04-19 01:17:38 +03:00
|
|
|
lwc_string *imime_type, const struct http_parameter *params,
|
2016-06-06 10:59:23 +03:00
|
|
|
struct llcache_handle *llcache, const char *fallback_charset,
|
2011-05-07 00:40:09 +04:00
|
|
|
bool quirks, struct content **c)
|
|
|
|
{
|
2011-08-31 16:12:41 +04:00
|
|
|
amiga_icon_content *ai_content;
|
2011-05-07 00:40:09 +04:00
|
|
|
nserror error;
|
|
|
|
|
2012-10-03 22:24:58 +04:00
|
|
|
ai_content = calloc(1, sizeof(amiga_icon_content));
|
2011-08-31 16:12:41 +04:00
|
|
|
if (ai_content == NULL)
|
2011-05-07 00:40:09 +04:00
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
2011-08-31 16:12:41 +04:00
|
|
|
error = content__init(&ai_content->base, handler, imime_type, params,
|
2011-05-07 00:40:09 +04:00
|
|
|
llcache, fallback_charset, quirks);
|
|
|
|
if (error != NSERROR_OK) {
|
2012-10-03 22:24:58 +04:00
|
|
|
free(ai_content);
|
2011-05-07 00:40:09 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2011-08-31 16:12:41 +04:00
|
|
|
*c = (struct content *)ai_content;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-30 18:23:38 +04:00
|
|
|
/**
|
|
|
|
* Convert a CONTENT_AMIGA_ICON for display.
|
|
|
|
*
|
|
|
|
* No conversion is necessary. We merely read the icon dimensions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool amiga_icon_convert(struct content *c)
|
|
|
|
{
|
2011-08-31 16:12:41 +04:00
|
|
|
amiga_icon_content *icon_c = (amiga_icon_content *)c;
|
2010-10-30 18:23:38 +04:00
|
|
|
union content_msg_data msg_data;
|
|
|
|
struct DiskObject *dobj;
|
|
|
|
ULONG *imagebuf;
|
|
|
|
unsigned char *imagebufptr = NULL;
|
|
|
|
ULONG size;
|
|
|
|
int width = 0, height = 0;
|
|
|
|
long format = 0;
|
|
|
|
uint8 r, g, b, a;
|
|
|
|
ULONG offset;
|
2014-05-27 02:43:36 +04:00
|
|
|
char *filename = NULL;
|
2010-10-30 18:23:38 +04:00
|
|
|
char *p;
|
2010-10-31 14:14:26 +03:00
|
|
|
ULONG trans, pals1;
|
|
|
|
struct ColorRegister *pal1;
|
2010-10-30 18:23:38 +04:00
|
|
|
|
2014-05-27 02:43:36 +04:00
|
|
|
netsurf_nsurl_to_path(content_get_url(c), &filename);
|
2010-10-30 18:23:38 +04:00
|
|
|
/* This loader will only work on local files, so fail if not a local path */
|
|
|
|
if(filename == NULL)
|
|
|
|
{
|
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = strstr(filename, ".info");
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
dobj = GetIconTagList(filename, NULL);
|
|
|
|
|
|
|
|
if(dobj == NULL)
|
|
|
|
{
|
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-15 22:58:24 +03:00
|
|
|
IconControl(dobj,
|
2010-10-30 18:23:38 +04:00
|
|
|
ICONCTRLA_GetImageDataFormat,&format,
|
|
|
|
ICONCTRLA_GetWidth,&width,
|
|
|
|
ICONCTRLA_GetHeight,&height,
|
|
|
|
TAG_DONE);
|
|
|
|
|
2010-10-31 14:14:26 +03:00
|
|
|
/* Check icon is direct mapped (truecolour) or palette-mapped colour.
|
|
|
|
We need additional code to handle planar icons */
|
2011-01-08 03:08:47 +03:00
|
|
|
if((format != IDFMT_DIRECTMAPPED) && (format==IDFMT_PALETTEMAPPED)) {
|
|
|
|
if(dobj) FreeDiskObject(dobj);
|
2010-10-31 14:14:26 +03:00
|
|
|
return false;
|
2011-01-08 03:08:47 +03:00
|
|
|
}
|
2010-10-30 18:23:38 +04:00
|
|
|
|
2015-04-17 00:36:29 +03:00
|
|
|
icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NEW);
|
2011-08-31 16:12:41 +04:00
|
|
|
if (!icon_c->bitmap) {
|
2010-10-30 18:23:38 +04:00
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
2010-10-31 14:14:26 +03:00
|
|
|
if(dobj) FreeDiskObject(dobj);
|
2010-10-30 18:23:38 +04:00
|
|
|
return false;
|
|
|
|
}
|
2015-04-17 00:36:29 +03:00
|
|
|
imagebuf = (ULONG *) amiga_bitmap_get_buffer(icon_c->bitmap);
|
2010-10-30 18:23:38 +04:00
|
|
|
if (!imagebuf) {
|
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
2010-10-31 14:14:26 +03:00
|
|
|
if(dobj) FreeDiskObject(dobj);
|
2010-10-30 18:23:38 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-15 22:58:24 +03:00
|
|
|
IconControl(dobj,
|
2010-10-30 18:23:38 +04:00
|
|
|
ICONCTRLA_GetImageData1, &imagebufptr,
|
|
|
|
TAG_DONE);
|
|
|
|
|
2010-10-31 14:14:26 +03:00
|
|
|
if(format==IDFMT_PALETTEMAPPED)
|
|
|
|
{
|
|
|
|
IconControl(dobj, ICONCTRLA_GetTransparentColor1, &trans,
|
|
|
|
ICONCTRLA_GetPalette1, &pal1,
|
|
|
|
ICONCTRLA_GetPaletteSize1, &pals1,
|
|
|
|
TAG_DONE);
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
imagebufptr = (unsigned char *) amiga_icon_convertcolouricon32((UBYTE *)imagebufptr,
|
2010-10-31 14:14:26 +03:00
|
|
|
width, height, trans, pals1, pal1, 0xff);
|
|
|
|
}
|
|
|
|
|
2010-10-30 18:23:38 +04:00
|
|
|
/* Decoded data is ARGB, so ensure correct byte order */
|
|
|
|
|
|
|
|
size = width * height * 4;
|
|
|
|
|
|
|
|
for (offset = 0; offset < size; offset += 4) {
|
|
|
|
b = imagebufptr[offset+3];
|
|
|
|
g = imagebufptr[offset+2];
|
|
|
|
r = imagebufptr[offset+1];
|
|
|
|
a = imagebufptr[offset];
|
|
|
|
|
|
|
|
*imagebuf = r << 24 | g << 16 | b << 8 | a;
|
|
|
|
imagebuf++;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->width = width;
|
|
|
|
c->height = height;
|
|
|
|
|
2015-04-17 00:36:29 +03:00
|
|
|
amiga_bitmap_modified(icon_c->bitmap);
|
2011-02-27 23:11:39 +03:00
|
|
|
content_set_ready(c);
|
|
|
|
content_set_done(c);
|
2010-10-30 18:23:38 +04:00
|
|
|
content_set_status(c, "");
|
2010-10-31 14:14:26 +03:00
|
|
|
|
|
|
|
if(dobj) FreeDiskObject(dobj);
|
|
|
|
|
2011-01-08 03:08:47 +03:00
|
|
|
if(format==IDFMT_PALETTEMAPPED)
|
|
|
|
FreeVec(imagebufptr);
|
|
|
|
|
2010-10-30 18:23:38 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy a CONTENT_AMIGA_ICON and free all resources it owns.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void amiga_icon_destroy(struct content *c)
|
|
|
|
{
|
2011-08-31 16:12:41 +04:00
|
|
|
amiga_icon_content *icon_c = (amiga_icon_content *)c;
|
|
|
|
|
|
|
|
if (icon_c->bitmap != NULL)
|
2015-04-17 00:36:29 +03:00
|
|
|
amiga_bitmap_destroy(icon_c->bitmap);
|
2010-10-30 18:23:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redraw a CONTENT_AMIGA_ICON.
|
|
|
|
*/
|
|
|
|
|
2011-06-29 12:33:28 +04:00
|
|
|
bool amiga_icon_redraw(struct content *c,
|
2011-06-30 19:48:07 +04:00
|
|
|
struct content_redraw_data *data, const struct rect *clip,
|
|
|
|
const struct redraw_context *ctx)
|
2010-10-30 18:23:38 +04:00
|
|
|
{
|
2011-08-31 16:12:41 +04:00
|
|
|
amiga_icon_content *icon_c = (amiga_icon_content *)c;
|
2011-05-09 02:18:28 +04:00
|
|
|
bitmap_flags_t flags = BITMAPF_NONE;
|
|
|
|
|
2011-06-29 12:33:28 +04:00
|
|
|
if (data->repeat_x)
|
2011-05-09 02:18:28 +04:00
|
|
|
flags |= BITMAPF_REPEAT_X;
|
2011-06-29 12:33:28 +04:00
|
|
|
if (data->repeat_y)
|
2011-05-09 02:18:28 +04:00
|
|
|
flags |= BITMAPF_REPEAT_Y;
|
|
|
|
|
2011-06-30 19:48:07 +04:00
|
|
|
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
|
2011-08-31 16:12:41 +04:00
|
|
|
icon_c->bitmap, data->background_colour, flags);
|
2010-10-30 18:23:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
nserror amiga_icon_clone(const struct content *old, struct content **newc)
|
2010-10-30 18:23:38 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
amiga_icon_content *ai;
|
|
|
|
nserror error;
|
|
|
|
|
2012-10-03 22:24:58 +04:00
|
|
|
ai = calloc(1, sizeof(amiga_icon_content));
|
2011-05-07 00:40:09 +04:00
|
|
|
if (ai == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__clone(old, &ai->base);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
content_destroy(&ai->base);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-10-30 18:23:38 +04:00
|
|
|
/* Simply replay convert */
|
|
|
|
if (old->status == CONTENT_STATUS_READY ||
|
|
|
|
old->status == CONTENT_STATUS_DONE) {
|
2011-05-07 00:40:09 +04:00
|
|
|
if (amiga_icon_convert(&ai->base) == false) {
|
|
|
|
content_destroy(&ai->base);
|
|
|
|
return NSERROR_CLONE_FAILED;
|
|
|
|
}
|
2010-10-30 18:23:38 +04:00
|
|
|
}
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
*newc = (struct content *) ai;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-03 13:27:42 +04:00
|
|
|
content_type amiga_icon_content_type(void)
|
2011-05-07 00:40:09 +04:00
|
|
|
{
|
|
|
|
return CONTENT_IMAGE;
|
2010-10-30 18:23:38 +04:00
|
|
|
}
|
2010-10-31 14:14:26 +03:00
|
|
|
|
2011-01-08 03:08:47 +03:00
|
|
|
#endif /* WITH_AMIGA_ICON */
|
|
|
|
|
2016-06-02 02:44:20 +03:00
|
|
|
static ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height,
|
2010-10-31 14:14:26 +03:00
|
|
|
ULONG trans, ULONG pals1, struct ColorRegister *pal1, int alpha)
|
|
|
|
{
|
|
|
|
ULONG *argbicon;
|
|
|
|
struct ColorRegister *colour;
|
|
|
|
struct ColorMap *cmap;
|
2014-11-09 22:40:19 +03:00
|
|
|
ULONG i;
|
2010-10-31 14:14:26 +03:00
|
|
|
ULONG a,r,g,b;
|
|
|
|
|
|
|
|
if (alpha==0) alpha=0xff;
|
|
|
|
|
2013-10-12 16:11:13 +04:00
|
|
|
argbicon = (ULONG *)AllocVecTagList(width*height*4, NULL);
|
2010-10-31 14:14:26 +03:00
|
|
|
if (!argbicon) return(NULL);
|
|
|
|
|
|
|
|
cmap=GetColorMap(pals1);
|
|
|
|
if(!cmap) return(NULL);
|
|
|
|
|
|
|
|
for(i=0;i<(width*height);i++)
|
|
|
|
{
|
|
|
|
colour = &pal1[icondata[i]];
|
|
|
|
|
|
|
|
if(icondata[i] == trans)
|
|
|
|
{
|
|
|
|
a=0x00;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a=alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = colour->red;
|
|
|
|
g = colour->green;
|
|
|
|
b = colour->blue;
|
|
|
|
|
|
|
|
argbicon[i] = (a << 24) +
|
|
|
|
(r << 16) +
|
|
|
|
(g << 8) +
|
|
|
|
(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(argbicon);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-10-08 03:12:12 +04:00
|
|
|
void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct DiskObject *dobj)
|
|
|
|
{
|
|
|
|
struct BitMap *bm = NULL;
|
|
|
|
ULONG *icondata1, *icondata2;
|
|
|
|
ULONG width, height;
|
|
|
|
long format = 0;
|
|
|
|
|
|
|
|
if(dobj == NULL) return;
|
|
|
|
|
2016-01-15 22:58:24 +03:00
|
|
|
IconControl(dobj,
|
2011-10-08 03:12:12 +04:00
|
|
|
ICONCTRLA_GetImageDataFormat,&format,
|
|
|
|
ICONCTRLA_GetImageData1,&icondata1,
|
|
|
|
ICONCTRLA_GetImageData2,&icondata2,
|
|
|
|
ICONCTRLA_GetWidth,&width,
|
|
|
|
ICONCTRLA_GetHeight,&height,
|
|
|
|
TAG_DONE);
|
|
|
|
|
|
|
|
if(format != IDFMT_DIRECTMAPPED) return;
|
2015-01-18 23:11:33 +03:00
|
|
|
#ifdef __amigaos4__
|
|
|
|
if ((icon != NULL) && (content_get_bitmap(icon) != NULL)) {
|
|
|
|
bm = ami_bitmap_get_native(content_get_bitmap(icon), 16, 16, NULL);
|
|
|
|
}
|
2011-10-08 03:12:12 +04:00
|
|
|
|
2015-01-18 23:11:33 +03:00
|
|
|
if(bm) {
|
|
|
|
BltBitMapTags(BLITA_SrcX, 0,
|
|
|
|
BLITA_SrcY, 0,
|
|
|
|
BLITA_DestX, width - 16,
|
|
|
|
BLITA_DestY, height - 16,
|
|
|
|
BLITA_Width, 16,
|
|
|
|
BLITA_Height, 16,
|
|
|
|
BLITA_Source, bm,
|
|
|
|
BLITA_Dest, icondata1,
|
|
|
|
BLITA_SrcType, BLITT_BITMAP,
|
|
|
|
BLITA_DestType, BLITT_ARGB32,
|
|
|
|
BLITA_DestBytesPerRow, width * 4,
|
|
|
|
BLITA_UseSrcAlpha, TRUE,
|
|
|
|
TAG_DONE);
|
2011-10-08 03:12:12 +04:00
|
|
|
|
2015-01-18 23:11:33 +03:00
|
|
|
BltBitMapTags(BLITA_SrcX, 0,
|
|
|
|
BLITA_SrcY, 0,
|
|
|
|
BLITA_DestX, width - 16,
|
|
|
|
BLITA_DestY, height - 16,
|
|
|
|
BLITA_Width, 16,
|
|
|
|
BLITA_Height, 16,
|
|
|
|
BLITA_Source, bm,
|
|
|
|
BLITA_Dest, icondata2,
|
|
|
|
BLITA_SrcType, BLITT_BITMAP,
|
|
|
|
BLITA_DestType, BLITT_ARGB32,
|
|
|
|
BLITA_DestBytesPerRow, width * 4,
|
|
|
|
BLITA_UseSrcAlpha, TRUE,
|
|
|
|
TAG_DONE);
|
2011-10-08 03:12:12 +04:00
|
|
|
}
|
2015-01-18 23:11:33 +03:00
|
|
|
#endif
|
2011-10-08 03:12:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void amiga_icon_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type)
|
2010-10-31 14:14:26 +03:00
|
|
|
{
|
|
|
|
struct DiskObject *dobj = NULL;
|
|
|
|
ULONG *icondata1, *icondata2;
|
|
|
|
ULONG width, height;
|
|
|
|
long format = 0;
|
2011-01-08 03:08:47 +03:00
|
|
|
ULONG trans1, pals1;
|
|
|
|
ULONG trans2, pals2;
|
|
|
|
struct ColorRegister *pal1;
|
|
|
|
struct ColorRegister *pal2;
|
2010-10-31 14:14:26 +03:00
|
|
|
|
2011-10-15 19:27:56 +04:00
|
|
|
if(icon == NULL) return;
|
|
|
|
|
2010-10-31 14:14:26 +03:00
|
|
|
if(!type)
|
|
|
|
{
|
|
|
|
dobj = GetIconTags(NULL,
|
|
|
|
ICONGETA_GetDefaultType, WBDRAWER,
|
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dobj = GetIconTags(NULL, ICONGETA_GetDefaultName, type,
|
|
|
|
ICONGETA_GetDefaultType, WBPROJECT,
|
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
|
2011-01-08 03:08:47 +03:00
|
|
|
if(dobj == NULL) return;
|
|
|
|
|
2016-01-15 22:58:24 +03:00
|
|
|
IconControl(dobj,
|
2010-10-31 14:14:26 +03:00
|
|
|
ICONCTRLA_GetImageDataFormat,&format,
|
|
|
|
ICONCTRLA_GetImageData1,&icondata1,
|
|
|
|
ICONCTRLA_GetImageData2,&icondata2,
|
|
|
|
ICONCTRLA_GetWidth,&width,
|
|
|
|
ICONCTRLA_GetHeight,&height,
|
|
|
|
TAG_DONE);
|
|
|
|
|
2011-01-08 03:08:47 +03:00
|
|
|
/* If we have a palette-mapped icon, convert it to a 32-bit one */
|
|
|
|
if(format == IDFMT_PALETTEMAPPED)
|
|
|
|
{
|
|
|
|
IconControl(dobj, ICONCTRLA_GetTransparentColor1, &trans1,
|
|
|
|
ICONCTRLA_GetPalette1, &pal1,
|
|
|
|
ICONCTRLA_GetPaletteSize1, &pals1,
|
|
|
|
ICONCTRLA_GetTransparentColor2, &trans2,
|
|
|
|
ICONCTRLA_GetPalette2, &pal2,
|
|
|
|
ICONCTRLA_GetPaletteSize2, &pals2,
|
|
|
|
TAG_DONE);
|
|
|
|
|
|
|
|
icondata1 = amiga_icon_convertcolouricon32((UBYTE *)icondata1,
|
|
|
|
width, height, trans1, pals1, pal1, 0xff);
|
|
|
|
|
|
|
|
icondata2 = amiga_icon_convertcolouricon32((UBYTE *)icondata2,
|
|
|
|
width, height, trans2, pals2, pal2, 0xff);
|
|
|
|
|
2016-01-15 22:58:24 +03:00
|
|
|
IconControl(dobj,
|
2011-01-08 03:08:47 +03:00
|
|
|
ICONCTRLA_SetImageDataFormat, IDFMT_DIRECTMAPPED,
|
|
|
|
ICONCTRLA_SetImageData1, icondata1,
|
|
|
|
ICONCTRLA_SetImageData2, icondata2,
|
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((format == IDFMT_DIRECTMAPPED) || (format == IDFMT_PALETTEMAPPED))
|
2011-10-08 03:12:12 +04:00
|
|
|
amiga_icon_superimpose_favicon_internal(icon, dobj);
|
2010-10-31 14:14:26 +03:00
|
|
|
|
|
|
|
PutIconTags(path, dobj,
|
|
|
|
ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE);
|
2011-01-08 03:08:47 +03:00
|
|
|
|
|
|
|
FreeDiskObject(dobj);
|
|
|
|
|
|
|
|
if(format == IDFMT_PALETTEMAPPED)
|
|
|
|
{
|
|
|
|
/* Free the 32-bit data we created */
|
|
|
|
FreeVec(icondata1);
|
|
|
|
FreeVec(icondata2);
|
|
|
|
}
|
2010-10-31 14:14:26 +03:00
|
|
|
}
|
2011-07-03 15:05:18 +04:00
|
|
|
|
|
|
|
struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm)
|
|
|
|
{
|
|
|
|
struct DiskObject *dobj;
|
|
|
|
struct BitMap *bitmap;
|
2016-03-22 22:26:36 +03:00
|
|
|
ULONG *icondata;
|
|
|
|
|
2015-01-18 23:11:33 +03:00
|
|
|
#ifdef __amigaos4__
|
2011-07-03 15:47:54 +04:00
|
|
|
if(bm)
|
|
|
|
{
|
2012-08-08 00:25:47 +04:00
|
|
|
bitmap = ami_bitmap_get_native(bm, THUMBNAIL_WIDTH,
|
2011-07-03 15:47:54 +04:00
|
|
|
THUMBNAIL_HEIGHT, NULL);
|
2016-03-22 22:26:36 +03:00
|
|
|
icondata = AllocVecTagList(THUMBNAIL_WIDTH * 4 * THUMBNAIL_HEIGHT, NULL);
|
2016-03-22 22:39:33 +03:00
|
|
|
ami_bitmap_set_icondata(bm, icondata);
|
2011-07-03 15:05:18 +04:00
|
|
|
|
2016-07-02 16:56:04 +03:00
|
|
|
if(bitmap) {
|
|
|
|
BltBitMapTags(BLITA_Width, THUMBNAIL_WIDTH,
|
|
|
|
BLITA_Height, THUMBNAIL_HEIGHT,
|
|
|
|
BLITA_SrcType, BLITT_BITMAP,
|
|
|
|
BLITA_Source, bitmap,
|
|
|
|
BLITA_DestType, BLITT_ARGB32,
|
|
|
|
BLITA_DestBytesPerRow, THUMBNAIL_WIDTH * 4,
|
|
|
|
BLITA_Dest, icondata,
|
2011-07-03 15:05:18 +04:00
|
|
|
TAG_DONE);
|
2016-07-02 16:56:04 +03:00
|
|
|
}
|
2011-07-03 15:47:54 +04:00
|
|
|
}
|
2015-01-18 23:11:33 +03:00
|
|
|
#endif
|
2011-07-03 15:47:54 +04:00
|
|
|
dobj = GetIconTags(NULL, ICONGETA_GetDefaultType, WBPROJECT,
|
|
|
|
ICONGETA_GetDefaultName, "iconify",
|
|
|
|
TAG_DONE);
|
2015-01-18 23:11:33 +03:00
|
|
|
#ifdef __amigaos4__
|
2011-07-03 15:47:54 +04:00
|
|
|
if(bm)
|
|
|
|
{
|
|
|
|
IconControl(dobj,
|
2011-07-03 15:05:18 +04:00
|
|
|
ICONCTRLA_SetImageDataFormat, IDFMT_DIRECTMAPPED,
|
2011-07-03 15:47:54 +04:00
|
|
|
ICONCTRLA_SetWidth, THUMBNAIL_WIDTH,
|
|
|
|
ICONCTRLA_SetHeight, THUMBNAIL_HEIGHT,
|
2016-03-22 22:26:36 +03:00
|
|
|
ICONCTRLA_SetImageData1, icondata,
|
2011-07-03 15:05:18 +04:00
|
|
|
ICONCTRLA_SetImageData2, NULL,
|
|
|
|
TAG_DONE);
|
2011-07-03 15:47:54 +04:00
|
|
|
}
|
2015-01-18 23:11:33 +03:00
|
|
|
#endif
|
2011-07-03 15:54:43 +04:00
|
|
|
dobj->do_Gadget.UserData = bm;
|
|
|
|
|
2011-07-03 15:05:18 +04:00
|
|
|
LayoutIconA(dobj, (struct Screen *)~0UL, NULL);
|
|
|
|
|
|
|
|
return dobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
void amiga_icon_free(struct DiskObject *dobj)
|
|
|
|
{
|
|
|
|
struct bitmap *bm = dobj->do_Gadget.UserData;
|
|
|
|
|
|
|
|
FreeDiskObject(dobj);
|
2016-03-22 22:26:36 +03:00
|
|
|
if(bm) FreeVec(ami_bitmap_get_icondata(bm));
|
2011-07-03 15:05:18 +04:00
|
|
|
}
|
2016-03-22 22:26:36 +03:00
|
|
|
|