forked from old/legacy-imlib2
remember to not free images made form external data if it wasnt copied.. and
free colors from color cubes once the context is invalid.. :) SVN revision: 139
This commit is contained in:
parent
61cf8c1643
commit
bc6a4e6343
13
api.c
13
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
|
||||
|
|
2
api.h
2
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
2
image.c
2
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);
|
||||
|
|
4
image.h
4
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))
|
||||
|
|
Loading…
Reference in New Issue