aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dicache.c8
-rw-r--r--src/dicache.h2
-rw-r--r--src/gif.c15
-rw-r--r--src/jpeg.c1
-rw-r--r--src/png.c9
5 files changed, 18 insertions, 17 deletions
diff --git a/src/dicache.c b/src/dicache.c
index 82043590..633d44f9 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -300,7 +300,7 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
/*
* Implement the set_cmap method for the Image
*/
-void a_Dicache_set_cmap(DilloUrl *url, int version, DilloImage *Image,
+void a_Dicache_set_cmap(DilloUrl *url, int version, int bg_color,
const uchar_t *cmap, uint_t num_colors,
int num_colors_max, int bg_index)
{
@@ -313,9 +313,9 @@ void a_Dicache_set_cmap(DilloUrl *url, int version, DilloImage *Image,
DicEntry->cmap = dNew0(uchar_t, 3 * num_colors_max);
memcpy(DicEntry->cmap, cmap, 3 * num_colors);
if (bg_index >= 0 && (uint_t)bg_index < num_colors) {
- DicEntry->cmap[bg_index * 3] = (Image->bg_color >> 16) & 0xff;
- DicEntry->cmap[bg_index * 3 + 1] = (Image->bg_color >> 8) & 0xff;
- DicEntry->cmap[bg_index * 3 + 2] = (Image->bg_color) & 0xff;
+ DicEntry->cmap[bg_index * 3] = (bg_color >> 16) & 0xff;
+ DicEntry->cmap[bg_index * 3 + 1] = (bg_color >> 8) & 0xff;
+ DicEntry->cmap[bg_index * 3 + 2] = (bg_color) & 0xff;
}
DicEntry->State = DIC_SetCmap;
diff --git a/src/dicache.h b/src/dicache.h
index df8a8b89..f1819b12 100644
--- a/src/dicache.h
+++ b/src/dicache.h
@@ -61,7 +61,7 @@ void a_Dicache_callback(int Op, CacheClient_t *Client);
void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
uint_t width, uint_t height, DilloImgType type,
double gamma);
-void a_Dicache_set_cmap(DilloUrl *url, int version, DilloImage *Image,
+void a_Dicache_set_cmap(DilloUrl *url, int version, int bg_color,
const uchar_t *cmap, uint_t num_colors,
int num_colors_max, int bg_index);
void a_Dicache_new_scan(const DilloUrl *url, int version);
diff --git a/src/gif.c b/src/gif.c
index 7ce1e110..34424d33 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -103,9 +103,7 @@ typedef struct {
size_t ColorMap_ofs;
uint_t ColorResolution;
uint_t NumColors;
-#if 0
- int Background;
-#endif
+ int Background;
uint_t spill_line_index;
#if 0
uint_t AspectRatio; /* AspectRatio (not used) */
@@ -165,9 +163,7 @@ void *a_Gif_new(DilloImage *Image, DilloUrl *url, int version)
gif->state = 0;
gif->Start_Ofs = 0;
gif->linebuf = NULL;
-#if 0
- gif->Background = -1;
-#endif
+ gif->Background = Image->bg_color;
gif->transparent = -1;
gif->num_spill_lines_max = 0;
gif->spill_lines = NULL;
@@ -222,7 +218,7 @@ static void Gif_write(DilloGif *gif, void *Buf, uint_t BufSize)
int bufsize, bytes_consumed;
/* Sanity checks */
- if (!Buf || !gif->Image || BufSize == 0)
+ if (!Buf || BufSize == 0)
return;
buf = ((uchar_t *) Buf) + gif->Start_Ofs;
@@ -820,6 +816,7 @@ static size_t Gif_do_img_desc(DilloGif *gif, void *Buf,
a_Dicache_set_parms(gif->url, gif->version, gif->Image,
gif->Width, gif->Height, DILLO_IMG_TYPE_INDEXED,
1 / 2.2);
+ gif->Image = NULL; /* safeguard: hereafter it may be freed by its owner */
Flags = buf[8];
@@ -850,8 +847,8 @@ static size_t Gif_do_img_desc(DilloGif *gif, void *Buf,
gif->spill_line_index = 0;
gif->linebuf = dMalloc(gif->Width);
gif->state = 3; /*Process the lzw data next */
- if (gif->Image && gif->ColorMap_ofs) {
- a_Dicache_set_cmap(gif->url, gif->version, gif->Image,
+ if (gif->ColorMap_ofs) {
+ a_Dicache_set_cmap(gif->url, gif->version, gif->Background,
(uchar_t *) Buf + gif->ColorMap_ofs,
gif->NumColors, 256, gif->transparent);
}
diff --git a/src/jpeg.c b/src/jpeg.c
index 625808fb..5652aa56 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -304,6 +304,7 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize)
(uint_t)jpeg->cinfo.image_width,
(uint_t)jpeg->cinfo.image_height,
type, 1 / 2.2);
+ jpeg->Image = NULL; /* safeguard: may be freed by its owner later */
/* decompression step 4 (see libjpeg.doc) */
jpeg->state = DILLO_JPEG_STARTING;
diff --git a/src/png.c b/src/png.c
index 4f5da1c2..093e2600 100644
--- a/src/png.c
+++ b/src/png.c
@@ -62,6 +62,7 @@ typedef struct {
DilloImage *Image; /* Image meta data */
DilloUrl *url; /* Primary Key for the dicache */
int version; /* Secondary Key for the dicache */
+ int bgcolor; /* Parent widget background color */
png_uint_32 width; /* png image width */
png_uint_32 height; /* png image height */
@@ -204,6 +205,7 @@ Png_datainfo_callback(png_structp png_ptr, png_infop info_ptr)
a_Dicache_set_parms(png->url, png->version, png->Image,
(uint_t)png->width, (uint_t)png->height,
DILLO_IMG_TYPE_RGB, file_gamma);
+ png->Image = NULL; /* safeguard: hereafter it may be freed by its owner */
}
static void
@@ -244,9 +246,9 @@ static void
/* TODO: maybe change prefs.bg_color to `a_Dw_widget_get_bg_color`,
* when background colors are correctly implementated */
- bg_blue = (png->Image->bg_color) & 0xFF;
- bg_green = (png->Image->bg_color>>8) & 0xFF;
- bg_red = (png->Image->bg_color>>16) & 0xFF;
+ bg_blue = (png->bgcolor) & 0xFF;
+ bg_green = (png->bgcolor>>8) & 0xFF;
+ bg_red = (png->bgcolor>>16) & 0xFF;
for (i = 0; i < png->width; i++) {
a = *(data+3);
@@ -433,6 +435,7 @@ void *a_Png_new(DilloImage *Image, DilloUrl *url, int version)
png->Image = Image;
png->url = url;
png->version = version;
+ png->bgcolor = Image->bg_color;
png->error = 0;
png->ipbuf = NULL;
png->ipbufstart = 0;