forked from old/legacy-imlib2
adding color modifier api backend stuff.... :)
SVN revision: 112
This commit is contained in:
parent
256ad43625
commit
61cf8c1643
45
api.c
45
api.c
|
@ -17,12 +17,6 @@
|
|||
typedef void (*Imlib_Internal_Progress_Function)(ImlibImage*, char,
|
||||
int, int, int, int);
|
||||
|
||||
char
|
||||
imlib_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
imlib_get_cache_size(void)
|
||||
{
|
||||
|
@ -117,7 +111,7 @@ imlib_free_image_and_decache(Imlib_Image image)
|
|||
}
|
||||
|
||||
int
|
||||
imlib_get_image_width(Imlib_Image image)
|
||||
imlib_image_get_width(Imlib_Image image)
|
||||
{
|
||||
ImlibImage *im;
|
||||
|
||||
|
@ -126,7 +120,7 @@ imlib_get_image_width(Imlib_Image image)
|
|||
}
|
||||
|
||||
int
|
||||
imlib_get_image_height(Imlib_Image image)
|
||||
imlib_image_get_height(Imlib_Image image)
|
||||
{
|
||||
ImlibImage *im;
|
||||
|
||||
|
@ -135,7 +129,7 @@ imlib_get_image_height(Imlib_Image image)
|
|||
}
|
||||
|
||||
DATA32 *
|
||||
imlib_get_image_data(Imlib_Image image)
|
||||
imlib_image_get_data(Imlib_Image image)
|
||||
{
|
||||
ImlibImage *im;
|
||||
|
||||
|
@ -148,7 +142,7 @@ imlib_get_image_data(Imlib_Image image)
|
|||
}
|
||||
|
||||
void
|
||||
imlib_put_back_image_data(Imlib_Image image)
|
||||
imlib_image_put_back_data(Imlib_Image image)
|
||||
{
|
||||
ImlibImage *im;
|
||||
|
||||
|
@ -207,6 +201,17 @@ imlib_image_set_border(Imlib_Image image, Imlib_Border *border)
|
|||
__imlib_DirtyPixmapsForImage(im);
|
||||
}
|
||||
|
||||
void
|
||||
imlib_image_set_format(Imlib_Image image, char *format)
|
||||
{
|
||||
ImlibImage *im;
|
||||
|
||||
CAST_IMAGE(im, image);
|
||||
if (im->format)
|
||||
free(im->format);
|
||||
im->format = strdup(format);
|
||||
}
|
||||
|
||||
char *
|
||||
imlib_image_format(Imlib_Image image)
|
||||
{
|
||||
|
@ -233,17 +238,21 @@ imlib_render_pixmaps_for_whole_image(Imlib_Image image, Display *display,
|
|||
Pixmap *mask_return,
|
||||
char anti_aliased_scaling,
|
||||
char dithered_rendering,
|
||||
char create_dithered_mask)
|
||||
char create_dithered_mask,
|
||||
Imlib_Color_Modifier color_modifier)
|
||||
{
|
||||
ImlibImage *im;
|
||||
ImlibColorModifier *cm;
|
||||
|
||||
CAST_IMAGE(im, image);
|
||||
cm = (ImlibColorModifier *)color_modifier;
|
||||
__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,
|
||||
dithered_rendering,
|
||||
create_dithered_mask);
|
||||
create_dithered_mask,
|
||||
color_modifier);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -255,17 +264,21 @@ imlib_render_pixmaps_for_whole_image_at_size(Imlib_Image image, Display *display
|
|||
char anti_aliased_scaling,
|
||||
char dithered_rendering,
|
||||
char create_dithered_mask,
|
||||
int width, int height)
|
||||
int width, int height,
|
||||
Imlib_Color_Modifier color_modifier)
|
||||
{
|
||||
ImlibImage *im;
|
||||
ImlibColorModifier *cm;
|
||||
|
||||
CAST_IMAGE(im, image);
|
||||
cm = (ImlibColorModifier *)color_modifier;
|
||||
__imlib_CreatePixmapsForImage(display, drawable, visual, depth, colormap,
|
||||
im, pixmap_return, mask_return, 0, 0,
|
||||
im->w, im->h, width, height,
|
||||
anti_aliased_scaling,
|
||||
dithered_rendering,
|
||||
create_dithered_mask);
|
||||
create_dithered_mask,
|
||||
color_modifier);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -350,7 +363,7 @@ imlib_create_image_using_copied_data(int width, int height,
|
|||
|
||||
im = __imlib_CreateImage(width, height, NULL);
|
||||
if (!im)
|
||||
return;
|
||||
return NULL;
|
||||
im->data = malloc(width * height *sizeof(DATA32));
|
||||
if (data)
|
||||
{
|
||||
|
@ -392,5 +405,3 @@ imlib_clone_image(Imlib_Image image)
|
|||
return (Imlib_Image)im;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
59
api.h
59
api.h
|
@ -10,6 +10,7 @@
|
|||
|
||||
/* data types - guess what - no transparent datatypes - all hidden */
|
||||
typedef void * Imlib_Image;
|
||||
typedef void * Imlib_Color_Modifier;
|
||||
typedef struct _imlib_border Imlib_Border;
|
||||
|
||||
struct _imlib_border
|
||||
|
@ -22,7 +23,6 @@ typedef void (*Imlib_Progress_Function)(Imlib_Image *im, char percent,
|
|||
int update_w, int update_h);
|
||||
|
||||
/* init and setup functions */
|
||||
char imlib_init(void);
|
||||
int imlib_get_cache_size(void);
|
||||
void imlib_set_cache_size(int bytes);
|
||||
int imlib_get_color_usage(void);
|
||||
|
@ -45,16 +45,17 @@ void imlib_free_image(Imlib_Image image);
|
|||
void imlib_free_image_and_decache(Imlib_Image image);
|
||||
|
||||
/* image information retrieval and basic manipulation functions */
|
||||
int imlib_get_image_width(Imlib_Image image);
|
||||
int imlib_get_image_height(Imlib_Image image);
|
||||
DATA32 *imlib_get_image_data(Imlib_Image image);
|
||||
int imlib_image_get_width(Imlib_Image image);
|
||||
int imlib_image_get_height(Imlib_Image image);
|
||||
DATA32 *imlib_image_get_data(Imlib_Image image);
|
||||
char imlib_image_has_alpha(Imlib_Image image);
|
||||
char *imlib_image_format(Imlib_Image image);
|
||||
void imlib_put_back_image_data(Imlib_Image image);
|
||||
void imlib_image_put_back_data(Imlib_Image image);
|
||||
void imlib_image_set_has_alpha(Imlib_Image image, char has_alpha);
|
||||
void imlib_image_set_never_changes_on_disk(Imlib_Image image);
|
||||
void imlib_image_get_border(Imlib_Image image, Imlib_Border *border);
|
||||
void imlib_image_set_border(Imlib_Image image, Imlib_Border *border);
|
||||
void imlib_image_set_format(Imlib_Image image, char *format);
|
||||
|
||||
/* image drawing/rendering functions */
|
||||
|
||||
|
@ -65,7 +66,8 @@ void imlib_render_pixmaps_for_whole_image(Imlib_Image image, Display *display,
|
|||
Pixmap *mask_return,
|
||||
char anti_aliased_scaling,
|
||||
char dithered_rendering,
|
||||
char create_dithered_mask);
|
||||
char create_dithered_mask,
|
||||
Imlib_Color_Modifier color_modifier);
|
||||
void imlib_render_pixmaps_for_whole_image_at_size(Imlib_Image image, Display *display,
|
||||
Drawable drawable, Visual *visual,
|
||||
Colormap colormap, int depth,
|
||||
|
@ -74,7 +76,8 @@ void imlib_render_pixmaps_for_whole_image_at_size(Imlib_Image image, Display *di
|
|||
char anti_aliased_scaling,
|
||||
char dithered_rendering,
|
||||
char create_dithered_mask,
|
||||
int width, int height);
|
||||
int width, int height,
|
||||
Imlib_Color_Modifier color_modifier);
|
||||
void imlib_render_image_on_drawable(Imlib_Image image, Display *display,
|
||||
Drawable drawable, Visual *visual,
|
||||
Colormap colormap, int depth,
|
||||
|
@ -97,9 +100,14 @@ void imlib_blend_image_onto_image(Imlib_Image source_image,
|
|||
int destination_x, int destination_y,
|
||||
int destination_width, int destination_height);
|
||||
|
||||
#if 0
|
||||
|
||||
/* FIXME: */
|
||||
/* draw line, polygon, rect - with option of drawing in rgb or alpha or both */
|
||||
/* apply alpha of one image to another */
|
||||
|
||||
#endif
|
||||
|
||||
/* image creation and grabbing */
|
||||
Imlib_Image imlib_create_image(int width, int height);
|
||||
Imlib_Image imlib_create_image_using_data(int width, int height,
|
||||
|
@ -113,6 +121,7 @@ Imlib_Image imlib_create_image_from_drawable(Display *display,
|
|||
int x, int y,
|
||||
int width, int height);
|
||||
Imlib_Image imlib_clone_image(Imlib_Image image);
|
||||
|
||||
#if 0
|
||||
Imlib_image imlib_create_cropped_image(Imlib_Image image,
|
||||
int x, int y, int width, int height);
|
||||
|
@ -122,6 +131,11 @@ Imlib_image imlib_create_cropped_scaled_image(Imlib_Image image,
|
|||
int source_height,
|
||||
int destination_width,
|
||||
int destination_height);
|
||||
Imlib_image imlib_create_image_from_xpm_data(unsigned char *data);
|
||||
|
||||
/* color stuff */
|
||||
int imlib_match_color(int red, int green, int blue);
|
||||
|
||||
/* image modification - geometry */
|
||||
void imlib_create_cropped_image(Imlib_Image image, int x, int y, int width,
|
||||
int height);
|
||||
|
@ -129,13 +143,42 @@ void imlib_cropp_scale_image(Imlib_Image image, int source_x, int source_y,
|
|||
int source_width, int source_height);
|
||||
|
||||
/* image modification - color */
|
||||
Imlib_Color_Modifier imlib_create_color_modifier(void);
|
||||
void imlib_free_color_modifier(Imlib_Color_Modifier color_modifier);
|
||||
void imlib_set_color_modifier_gamma(Imlib_Color_Modifier color_modifier,
|
||||
double gamma_value);
|
||||
void imlib_set_color_modifier_brightness(Imlib_Color_Modifier color_modifier,
|
||||
double brightness_value);
|
||||
void imlib_set_color_modifier_contrast(Imlib_Color_Modifier color_modifier,
|
||||
double contrast_value);
|
||||
void imlib_set_color_modifier_tables(Imlib_Color_Modifier color_modifier,
|
||||
DATA8 *red_table,
|
||||
DATA8 *green_table,
|
||||
DATA8 *blue_table);
|
||||
void imlib_apply_color_modifier(Imlib_Image image,
|
||||
Imlib_Color_Modifier color_modifier);
|
||||
|
||||
/* image modification - rotation */
|
||||
/* image modification - rotation / flipping */
|
||||
void imlib_image_flip_horizontal(Imlib_Image image);
|
||||
void imlib_image_flip_vertical(Imlib_Image image);
|
||||
void imlib_image_flip_diagonal(Imlib_Image image);
|
||||
|
||||
/* image modification - blur / sharpen */
|
||||
void imlib_image_blur(Imlib_Image image, int radius);
|
||||
void imlib_image_sharpen(Imlib_Image image, int radius);
|
||||
|
||||
/* image modification - special (seamless tile (h, v & both) etc) */
|
||||
void imlib_image_tile_horizontal(Imlib_Image image);
|
||||
void imlib_image_tile_vertical(Imlib_Image image);
|
||||
void imlib_image_tile(Imlib_Image image);
|
||||
|
||||
/* image saving functions */
|
||||
void imlib_save_image(Imlib_Image image, char *filename);
|
||||
|
||||
/* FIXME: have to figure out generic saving mechanism that lets savers have */
|
||||
/* options like quality, color , compression etc. */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
13
draw.c
13
draw.c
|
@ -10,14 +10,19 @@ __imlib_CreatePixmapsForImage(Display *d, Drawable w, Visual *v, int depth,
|
|||
Colormap cm, ImlibImage *im, Pixmap *p, Mask *m,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dw, int dh,
|
||||
char anitalias, char hiq, char dither_mask)
|
||||
char anitalias, char hiq, char dither_mask,
|
||||
ImlibColorModifier *cmod)
|
||||
{
|
||||
ImlibImagePixmap *ip = NULL;
|
||||
Pixmap pmap = 0;
|
||||
Pixmap mask = 0;
|
||||
|
||||
ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy, sw, sh, cm,
|
||||
anitalias, hiq, dither_mask);
|
||||
long long mod_count = 0;
|
||||
|
||||
if (cmod)
|
||||
mod_count = cmod->modification_count;
|
||||
ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy,
|
||||
sw, sh, cm, anitalias, hiq, dither_mask,
|
||||
mod_count);
|
||||
if (ip)
|
||||
{
|
||||
if (p)
|
||||
|
|
3
draw.h
3
draw.h
|
@ -5,5 +5,6 @@ __imlib_CreatePixmapsForImage(Display *d, Drawable w, Visual *v, int depth,
|
|||
Colormap cm, ImlibImage *im, Pixmap *p, Mask *m,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dw, int dh,
|
||||
char anitalias, char hiq, char dither_mask);
|
||||
char anitalias, char hiq, char dither_mask,
|
||||
ImlibColorModifier *cmod);
|
||||
#endif
|
||||
|
|
4
image.c
4
image.c
|
@ -233,7 +233,8 @@ __imlib_ConsumeImagePixmap(ImlibImagePixmap *ip)
|
|||
ImlibImagePixmap *
|
||||
__imlib_FindCachedImagePixmap(ImlibImage *im, int w, int h, Display *d, Visual *v,
|
||||
int depth, int sx, int sy, int sw, int sh, Colormap cm,
|
||||
char aa, char hiq, char dmask)
|
||||
char aa, char hiq, char dmask,
|
||||
long long modification_count)
|
||||
{
|
||||
ImlibImagePixmap *ip, *previous_ip;
|
||||
|
||||
|
@ -249,6 +250,7 @@ __imlib_FindCachedImagePixmap(ImlibImage *im, int w, int h, Display *d, Visual *
|
|||
(ip->source_x == sx) && (ip->source_x == sy) &&
|
||||
(ip->source_w == sw) && (ip->source_h == sh) &&
|
||||
(ip->colormap == cm) && (ip->antialias == aa) &&
|
||||
(ip->modification_count == modification_count) &&
|
||||
(ip->dither_mask == dmask) &&
|
||||
(ip->border.left == im->border.left) &&
|
||||
(ip->border.right == im->border.right) &&
|
||||
|
|
19
image.h
19
image.h
|
@ -8,6 +8,7 @@ typedef struct _imlibimage ImlibImage;
|
|||
typedef struct _imlibimagepixmap ImlibImagePixmap;
|
||||
typedef struct _imlibborder ImlibBorder;
|
||||
typedef struct _imlibloader ImlibLoader;
|
||||
typedef struct _imlib_color_modifier ImlibColorModifier;
|
||||
|
||||
enum _iflags
|
||||
{
|
||||
|
@ -19,6 +20,14 @@ enum _iflags
|
|||
F_INVALID = (1 << 4)
|
||||
};
|
||||
|
||||
struct _imlib_color_modifier
|
||||
{
|
||||
DATA8 red_mapping[256];
|
||||
DATA8 green_mapping[256];
|
||||
DATA8 blue_mapping[256];
|
||||
long long modification_count;
|
||||
};
|
||||
|
||||
struct _imlibborder
|
||||
{
|
||||
int left, right, top, bottom;
|
||||
|
@ -52,6 +61,7 @@ struct _imlibimagepixmap
|
|||
ImlibImage *image;
|
||||
char dirty;
|
||||
int references;
|
||||
long long modification_count;
|
||||
ImlibImagePixmap *next;
|
||||
};
|
||||
|
||||
|
@ -86,10 +96,11 @@ void __imlib_CleanupImageCache(void);
|
|||
ImlibImagePixmap *__imlib_ProduceImagePixmap(void);
|
||||
void __imlib_ConsumeImagePixmap(ImlibImagePixmap *ip);
|
||||
ImlibImagePixmap *__imlib_FindCachedImagePixmap(ImlibImage *im, int w, int h,
|
||||
Display *d, Visual *v,
|
||||
int depth, int sx, int sy,
|
||||
int sw, int sh, Colormap cm,
|
||||
char aa, char hiq, char dmask);
|
||||
Display *d, Visual *v,
|
||||
int depth, int sx, int sy,
|
||||
int sw, int sh, Colormap cm,
|
||||
char aa, char hiq, char dmask,
|
||||
long long modification_count);
|
||||
void __imlib_AddImagePixmapToCache(ImlibImagePixmap *ip);
|
||||
void __imlib_RemoveImagePixmapFromCache(ImlibImagePixmap *ip);
|
||||
void __imlib_CleanupImagePixmapCache(void);
|
||||
|
|
9
main.c
9
main.c
|
@ -197,7 +197,6 @@ int main (int argc, char **argv)
|
|||
}
|
||||
}
|
||||
disp = XOpenDisplay(NULL);
|
||||
imlib_init();
|
||||
printf("load\n");
|
||||
im = malloc(sizeof(Imlib_Image) * (argc - start));
|
||||
for (i = start; i < argc; i++)
|
||||
|
@ -209,8 +208,8 @@ int main (int argc, char **argv)
|
|||
__imlib_SetMaxXImageCount(disp, 0);
|
||||
XSync(disp, False);
|
||||
printf("init\n");
|
||||
w = imlib_get_image_width(im[0]);
|
||||
h = imlib_get_image_height(im[0]);
|
||||
w = imlib_image_get_width(im[0]);
|
||||
h = imlib_image_get_height(im[0]);
|
||||
/*
|
||||
gc = XCreateGC(disp, win, 0, &gcv);
|
||||
back = XCreatePixmap(disp, win, w, h, depth);
|
||||
|
@ -222,8 +221,8 @@ int main (int argc, char **argv)
|
|||
x, y, w, h);
|
||||
tmp = imlib_clone_image(grab);
|
||||
|
||||
data1 = imlib_get_image_data(grab);
|
||||
data2 = imlib_get_image_data(tmp);
|
||||
data1 = imlib_image_get_data(grab);
|
||||
data2 = imlib_image_get_data(tmp);
|
||||
|
||||
printf("animate\n");
|
||||
for(;;)
|
||||
|
|
Loading…
Reference in New Issue