diff --git a/api.c b/api.c index c1d2ad1..bcbf9f8 100644 --- a/api.c +++ b/api.c @@ -236,7 +236,6 @@ imlib_render_pixmaps_for_whole_image(Imlib_Image image, Display *display, Colormap colormap, int depth, Pixmap *pixmap_return, Pixmap *mask_return, - char anti_aliased_scaling, char dithered_rendering, char create_dithered_mask, Imlib_Color_Modifier color_modifier) @@ -249,7 +248,7 @@ imlib_render_pixmaps_for_whole_image(Imlib_Image image, Display *display, __imlib_CreatePixmapsForImage(display, drawable, visual, depth, colormap, im, pixmap_return, mask_return, 0, 0, im->w, im->h, im->w, im->h, - anti_aliased_scaling, + 0, dithered_rendering, create_dithered_mask, color_modifier); @@ -285,7 +284,6 @@ void imlib_render_image_on_drawable(Imlib_Image image, Display *display, Drawable drawable, Visual *visual, Colormap colormap, int depth, - char anti_aliased_scaling, char dithered_rendering, char alpha_blending, int x, int y) @@ -295,7 +293,7 @@ imlib_render_image_on_drawable(Imlib_Image image, Display *display, CAST_IMAGE(im, image); __imlib_RenderImage(display, im, drawable, 0, visual, colormap, depth, 0, 0, im->w, im->h, x, y, im->w, im->h, - anti_aliased_scaling, + 0, dithered_rendering, alpha_blending, 0); } @@ -352,7 +350,12 @@ Imlib_Image imlib_create_image_using_data(int width, int height, DATA32 *data) { - return (Imlib_Image)__imlib_CreateImage(width, height, data); + ImlibImage *im; + + im = __imlib_CreateImage(width, height, data); + if (im) + SET_FLAG(im->flags, F_DONT_FREE_DATA); + return (Imlib_Image)im; } Imlib_Image diff --git a/api.h b/api.h index 2970bc2..cf1da09 100644 --- a/api.h +++ b/api.h @@ -64,7 +64,6 @@ void imlib_render_pixmaps_for_whole_image(Imlib_Image image, Display *display, Colormap colormap, int depth, Pixmap *pixmap_return, Pixmap *mask_return, - char anti_aliased_scaling, char dithered_rendering, char create_dithered_mask, Imlib_Color_Modifier color_modifier); @@ -81,7 +80,6 @@ void imlib_render_pixmaps_for_whole_image_at_size(Imlib_Image image, Display *di void imlib_render_image_on_drawable(Imlib_Image image, Display *display, Drawable drawable, Visual *visual, Colormap colormap, int depth, - char anti_aliased_scaling, char dithered_rendering, char alpha_blending, int x, int y); diff --git a/context.c b/context.c index 24448ed..626cf55 100644 --- a/context.c +++ b/context.c @@ -43,6 +43,14 @@ __imlib_FlushContexts(void) pct->next = ctt->next; if (ctt->palette) { + int i, num[] = { 256, 128, 64, 32, 16, 8, 1 }; + unsigned long pixels[256]; + + for (i = 0; i < num[ctt->palette_type]; i++) + pixels[i] = (unsigned long)ctt->palette[i]; + XFreeColors(ctt->display, ctt->colormap, pixels, + num[ctt->palette_type], 0); + free(ctt->palette); free(ctt->r_dither); free(ctt->g_dither); diff --git a/image.c b/image.c index 18d8471..b0aa47d 100644 --- a/image.c +++ b/image.c @@ -46,7 +46,7 @@ __imlib_ConsumeImage(ImlibImage *im) { if (im->file) free(im->file); - if (im->data) + if ((IMAGE_FREE_DATA(im)) && (im->data)) free(im->data); if (im->format) free(im->format); diff --git a/image.h b/image.h index 14ba9c4..34dac69 100644 --- a/image.h +++ b/image.h @@ -17,7 +17,8 @@ enum _iflags F_UNLOADED = (1 << 1), F_UNCACHEABLE = (1 << 2), F_ALWAYS_CHECK_DISK = (1 << 3), - F_INVALID = (1 << 4) + F_INVALID = (1 << 4), + F_DONT_FREE_DATA = (1 << 5) }; struct _imlib_color_modifier @@ -131,6 +132,7 @@ void __imlib_DirtyImage(ImlibImage *im); # define IMAGE_IS_UNCACHEABLE(im) ((im)->flags & F_UNCACHEABLE) # define IMAGE_ALWAYS_CHECK_DISK(im) ((im)->flags & F_ALWAYS_CHECK_DISK) # define IMAGE_IS_VALID(im) (!((im)->flags & F_INVALID)) +# define IMAGE_FREE_DATA(im) (!((im)->flags & F_DONT_FREE_DATA)) # define SET_FLAG(flags, f) ((flags) |= (f)) # define UNSET_FLAG(flags, f) ((flags) &= (~f)) diff --git a/main.c b/main.c index d7e769f..9601aec 100644 --- a/main.c +++ b/main.c @@ -231,7 +231,7 @@ int main (int argc, char **argv) { imlib_blend_image_onto_image(im[i], tmp, 0, 0, w, h, 0, 0, w, h); imlib_render_image_on_drawable(tmp, disp, win, vis, cm, depth, - 0, dith, 0, + dith, 0, x, y); memcpy(data2, data1, w * h *sizeof(DATA32)); }