From e423fc372df799f69cfe9903785e398fb9fd0a79 Mon Sep 17 00:00:00 2001 From: Tom Gilbert Date: Wed, 30 Aug 2000 16:39:44 +0000 Subject: [PATCH] Added rectangle clipping, in the form: void imlib_image_draw_rectangle_clipped(int x, int y, int width, int height, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax); Works well. If you make install then cd test, make, ./imlib2, you'll see the demo/test of the clipping code. Next up: draw_polygon and draw_polygon_clipped. Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image blending (fun). SVN revision: 3276 --- src/Imlib2.h | 4 + src/api.c | 2428 +++++++++++++++++++++++++----------------------- src/rgbadraw.c | 23 +- src/rgbadraw.h | 5 + test/main.c | 52 +- 5 files changed, 1334 insertions(+), 1178 deletions(-) diff --git a/src/Imlib2.h b/src/Imlib2.h index ca88657..edfc7f3 100644 --- a/src/Imlib2.h +++ b/src/Imlib2.h @@ -233,6 +233,10 @@ Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_up * rectangle */ Imlib_Updates imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax, char make_updates); void imlib_image_draw_rectangle(int x, int y, int width, int height); +void +imlib_image_draw_rectangle_clipped(int x, int y, int width, int height, + int clip_xmin, int clip_xmax, int clip_ymin, + int clip_ymax); void imlib_image_fill_rectangle(int x, int y, int width, int height); void imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y); void imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source, int x, int y, int width, int height, int destination_x, int destination_y); diff --git a/src/api.c b/src/api.c index bb9256d..433dc49 100644 --- a/src/api.c +++ b/src/api.c @@ -60,57 +60,57 @@ if (!(param)) \ } /* internal typedefs for function pointers */ -typedef void (*Imlib_Internal_Progress_Function)(void *, char, - int, int, int, int); -typedef void (*Imlib_Internal_Data_Destructor_Function)(void *, void *); +typedef void (*Imlib_Internal_Progress_Function) (void *, char, int, int, + int, int); +typedef void (*Imlib_Internal_Data_Destructor_Function) (void *, void *); /* context - all operations use this context for their state */ -static Display *ctxt_display = NULL; -static Visual *ctxt_visual = NULL; -static Colormap ctxt_colormap = 0; -static int ctxt_depth = 0; -static Drawable ctxt_drawable = 0; -static Pixmap ctxt_mask = 0; -static char ctxt_anti_alias = 1; -static char ctxt_dither = 0; -static char ctxt_blend = 1; -static Imlib_Color_Modifier ctxt_color_modifier = NULL; -static Imlib_Operation ctxt_operation = IMLIB_OP_COPY; -static Imlib_Font ctxt_font = NULL; -static Imlib_Text_Direction ctxt_direction = IMLIB_TEXT_TO_RIGHT; -static double ctxt_angle = 0.0; -static Imlib_Color ctxt_color = {255, 255, 255, 255}; -static Imlib_Color_Range ctxt_color_range = NULL; -static Imlib_Image ctxt_image = NULL; -static Imlib_Progress_Function ctxt_progress_func = NULL; -static char ctxt_progress_granularity = 0; -static char ctxt_dither_mask = 0; -static Imlib_Filter ctxt_filter = NULL; +static Display *ctxt_display = NULL; +static Visual *ctxt_visual = NULL; +static Colormap ctxt_colormap = 0; +static int ctxt_depth = 0; +static Drawable ctxt_drawable = 0; +static Pixmap ctxt_mask = 0; +static char ctxt_anti_alias = 1; +static char ctxt_dither = 0; +static char ctxt_blend = 1; +static Imlib_Color_Modifier ctxt_color_modifier = NULL; +static Imlib_Operation ctxt_operation = IMLIB_OP_COPY; +static Imlib_Font ctxt_font = NULL; +static Imlib_Text_Direction ctxt_direction = IMLIB_TEXT_TO_RIGHT; +static double ctxt_angle = 0.0; +static Imlib_Color ctxt_color = { 255, 255, 255, 255 }; +static Imlib_Color_Range ctxt_color_range = NULL; +static Imlib_Image ctxt_image = NULL; +static Imlib_Progress_Function ctxt_progress_func = NULL; +static char ctxt_progress_granularity = 0; +static char ctxt_dither_mask = 0; +static Imlib_Filter ctxt_filter = NULL; /* context setting/getting functions */ void -imlib_context_set_display(Display *display) +imlib_context_set_display(Display * display) { ctxt_display = display; } -Display * +Display * imlib_context_get_display(void) { - return ctxt_display; + return ctxt_display; } void -imlib_context_set_visual(Visual *visual) +imlib_context_set_visual(Visual * visual) { ctxt_visual = visual; ctxt_depth = imlib_get_visual_depth(ctxt_display, ctxt_visual); } -Visual * +Visual * imlib_context_get_visual(void) { - return ctxt_visual; + return ctxt_visual; } void @@ -119,10 +119,9 @@ imlib_context_set_colormap(Colormap colormap) ctxt_colormap = colormap; } -Colormap -imlib_context_get_colormap(void) +Colormap imlib_context_get_colormap(void) { - return ctxt_colormap; + return ctxt_colormap; } void @@ -131,10 +130,9 @@ imlib_context_set_drawable(Drawable drawable) ctxt_drawable = drawable; } -Drawable -imlib_context_get_drawable(void) +Drawable imlib_context_get_drawable(void) { - return ctxt_drawable; + return ctxt_drawable; } void @@ -143,10 +141,9 @@ imlib_context_set_mask(Pixmap mask) ctxt_mask = mask; } -Pixmap -imlib_context_get_mask(void) +Pixmap imlib_context_get_mask(void) { - return ctxt_mask; + return ctxt_mask; } void @@ -158,7 +155,7 @@ imlib_context_set_dither_mask(char dither_mask) char imlib_context_get_dither_mask(void) { - return ctxt_dither_mask; + return ctxt_dither_mask; } void @@ -170,7 +167,7 @@ imlib_context_set_anti_alias(char anti_alias) char imlib_context_get_anti_alias(void) { - return ctxt_anti_alias; + return ctxt_anti_alias; } void @@ -182,7 +179,7 @@ imlib_context_set_dither(char dither) char imlib_context_get_dither(void) { - return ctxt_dither; + return ctxt_dither; } void @@ -194,7 +191,7 @@ imlib_context_set_blend(char blend) char imlib_context_get_blend(void) { - return ctxt_blend; + return ctxt_blend; } void @@ -203,10 +200,9 @@ imlib_context_set_color_modifier(Imlib_Color_Modifier color_modifier) ctxt_color_modifier = color_modifier; } -Imlib_Color_Modifier -imlib_context_get_color_modifier(void) +Imlib_Color_Modifier imlib_context_get_color_modifier(void) { - return ctxt_color_modifier; + return ctxt_color_modifier; } void @@ -215,10 +211,9 @@ imlib_context_set_operation(Imlib_Operation operation) ctxt_operation = operation; } -Imlib_Operation -imlib_context_get_operation(void) +Imlib_Operation imlib_context_get_operation(void) { - return ctxt_operation; + return ctxt_operation; } void @@ -227,10 +222,9 @@ imlib_context_set_font(Imlib_Font font) ctxt_font = font; } -Imlib_Font -imlib_context_get_font(void) +Imlib_Font imlib_context_get_font(void) { - return ctxt_font; + return ctxt_font; } void @@ -251,34 +245,33 @@ imlib_context_get_angle(void) return ctxt_angle; } -Imlib_Text_Direction -imlib_context_get_direction(void) +Imlib_Text_Direction imlib_context_get_direction(void) { - return ctxt_direction; + return ctxt_direction; } void imlib_context_set_color(int red, int green, int blue, int alpha) { - ctxt_color.red = red; + ctxt_color.red = red; ctxt_color.green = green; - ctxt_color.blue = blue; + ctxt_color.blue = blue; ctxt_color.alpha = alpha; } void imlib_context_get_color(int *red, int *green, int *blue, int *alpha) { - *red = ctxt_color.red; - *green = ctxt_color.green; - *blue = ctxt_color.blue; - *alpha = ctxt_color.alpha; + *red = ctxt_color.red; + *green = ctxt_color.green; + *blue = ctxt_color.blue; + *alpha = ctxt_color.alpha; } -Imlib_Color * +Imlib_Color * imlib_context_get_imlib_color(void) { - return &ctxt_color; + return &ctxt_color; } void @@ -287,10 +280,9 @@ imlib_context_set_color_range(Imlib_Color_Range color_range) ctxt_color_range = color_range; } -Imlib_Color_Range -imlib_context_get_color_range(void) +Imlib_Color_Range imlib_context_get_color_range(void) { - return ctxt_color_range; + return ctxt_color_range; } void @@ -299,10 +291,9 @@ imlib_context_set_progress_function(Imlib_Progress_Function progress_function) ctxt_progress_func = progress_function; } -Imlib_Progress_Function -imlib_context_get_progress_function(void) +Imlib_Progress_Function imlib_context_get_progress_function(void) { - return ctxt_progress_func; + return ctxt_progress_func; } void @@ -314,7 +305,7 @@ imlib_context_set_progress_granularity(char progress_granularity) char imlib_context_get_progress_granularity(void) { - return ctxt_progress_granularity; + return ctxt_progress_granularity; } void @@ -323,20 +314,19 @@ imlib_context_set_image(Imlib_Image image) ctxt_image = image; } -Imlib_Image -imlib_context_get_image(void) +Imlib_Image imlib_context_get_image(void) { - return ctxt_image; + return ctxt_image; } /* imlib api */ -int +int imlib_get_cache_size(void) { return __imlib_GetCacheSize(); } -void +void imlib_set_cache_size(int bytes) { __imlib_SetCacheSize(bytes); @@ -348,7 +338,7 @@ imlib_get_color_usage(void) return (int)_max_colors; } -void +void imlib_set_color_usage(int max) { if (max < 2) @@ -365,118 +355,127 @@ imlib_flush_loaders(void) LTDL_Exit(); } -int -imlib_get_visual_depth(Display *display, Visual *visual) +int +imlib_get_visual_depth(Display * display, Visual * visual) { CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "display", display, 0); CHECK_PARAM_POINTER_RETURN("imlib_get_visual_depth", "visual", visual, 0); return __imlib_XActualDepth(display, visual); } -Visual * -imlib_get_best_visual(Display *display, int screen, int *depth_return) +Visual * +imlib_get_best_visual(Display * display, int screen, int *depth_return) { - CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "display", display, NULL); - CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "depth_return", depth_return, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "display", display, + NULL); + CHECK_PARAM_POINTER_RETURN("imlib_get_best_visual", "depth_return", + depth_return, NULL); return __imlib_BestVisual(display, screen, depth_return); } -Imlib_Image -imlib_load_image(const char *file) +Imlib_Image imlib_load_image(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; - + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; + CHECK_PARAM_POINTER_RETURN("imlib_load_image", "file", file, NULL); prev_ctxt_image = ctxt_image; - im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func, - ctxt_progress_granularity, 0, 0, NULL); + im = + __imlib_LoadImage(file, (ImlibProgressFunction) ctxt_progress_func, + ctxt_progress_granularity, 0, 0, NULL); ctxt_image = prev_ctxt_image; - return (Imlib_Image)im; + return (Imlib_Image) im; } -Imlib_Image -imlib_load_image_immediately(const char *file) +Imlib_Image imlib_load_image_immediately(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; - - CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately", "file", file, NULL); + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; + + CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately", "file", file, + NULL); prev_ctxt_image = ctxt_image; - im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func, - ctxt_progress_granularity, 1, 0, NULL); + im = + __imlib_LoadImage(file, (ImlibProgressFunction) ctxt_progress_func, + ctxt_progress_granularity, 1, 0, NULL); ctxt_image = prev_ctxt_image; - return (Imlib_Image)im; + return (Imlib_Image) im; } -Imlib_Image -imlib_load_image_without_cache(const char *file) +Imlib_Image imlib_load_image_without_cache(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; - - CHECK_PARAM_POINTER_RETURN("imlib_load_image_without_cache", "file", file, NULL); + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; + + CHECK_PARAM_POINTER_RETURN("imlib_load_image_without_cache", "file", file, + NULL); prev_ctxt_image = ctxt_image; - im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func, - ctxt_progress_granularity, 0, 1, NULL); + im = + __imlib_LoadImage(file, (ImlibProgressFunction) ctxt_progress_func, + ctxt_progress_granularity, 0, 1, NULL); ctxt_image = prev_ctxt_image; - return (Imlib_Image)im; + return (Imlib_Image) im; } -Imlib_Image -imlib_load_image_immediately_without_cache(const char *file) +Imlib_Image imlib_load_image_immediately_without_cache(const char *file) { - Imlib_Image im = NULL; - Imlib_Image prev_ctxt_image; - - CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately_without_cache", "file", file, NULL); + Imlib_Image im = NULL; + Imlib_Image prev_ctxt_image; + + CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately_without_cache", + "file", file, NULL); prev_ctxt_image = ctxt_image; - im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func, - ctxt_progress_granularity, 1, 1, NULL); + im = + __imlib_LoadImage(file, (ImlibProgressFunction) ctxt_progress_func, + ctxt_progress_granularity, 1, 1, NULL); ctxt_image = prev_ctxt_image; - return (Imlib_Image)im; + return (Imlib_Image) im; } -Imlib_Image -imlib_load_image_with_error_return(const char *file, Imlib_Load_Error *error_return) +Imlib_Image imlib_load_image_with_error_return(const char *file, + Imlib_Load_Error * error_return) { - Imlib_Image im = NULL; - ImlibLoadError er; - Imlib_Image prev_ctxt_image; - - CHECK_PARAM_POINTER_RETURN("imlib_load_image_with_error_return", "file", file, NULL); + Imlib_Image im = NULL; + ImlibLoadError er; + Imlib_Image prev_ctxt_image; + + CHECK_PARAM_POINTER_RETURN("imlib_load_image_with_error_return", "file", + file, NULL); if (!__imlib_FileExists(file)) - { - *error_return = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST; - return NULL; - } + { + *error_return = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST; + return NULL; + } if (__imlib_FileIsDir(file)) - { - *error_return = IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY; - return NULL; - } + { + *error_return = IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY; + return NULL; + } if (!__imlib_FileCanRead(file)) - { - *error_return = IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ; - return NULL; - } + { + *error_return = IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ; + return NULL; + } prev_ctxt_image = ctxt_image; - im = (Imlib_Image)__imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func, - ctxt_progress_granularity, 1, 0, &er); + im = + (Imlib_Image) __imlib_LoadImage(file, + (ImlibProgressFunction) + ctxt_progress_func, + ctxt_progress_granularity, 1, 0, &er); ctxt_image = prev_ctxt_image; if (im) *error_return = IMLIB_LOAD_ERROR_NONE; else - { - if (er == IMLIB_LOAD_ERROR_NONE) - *error_return = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT; - else - *error_return = (Imlib_Load_Error)er; - } + { + if (er == IMLIB_LOAD_ERROR_NONE) + *error_return = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT; + else + *error_return = (Imlib_Load_Error) er; + } return im; } -void +void imlib_free_image(void) { CHECK_PARAM_POINTER("imlib_free_image", "image", ctxt_image); @@ -484,10 +483,10 @@ imlib_free_image(void) ctxt_image = NULL; } -void +void imlib_free_image_and_decache(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_free_image_and_decache", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -496,43 +495,45 @@ imlib_free_image_and_decache(void) ctxt_image = NULL; } -int +int imlib_image_get_width(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER_RETURN("imlib_image_get_width", "image", ctxt_image, 0); CAST_IMAGE(im, ctxt_image); return im->w; } -int +int imlib_image_get_height(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER_RETURN("imlib_image_get_height", "image", ctxt_image, 0); CAST_IMAGE(im, ctxt_image); return im->h; } -const char * +const char * imlib_image_get_filename(void) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER_RETURN("imlib_image_get_filename", "image", ctxt_image, 0); + CHECK_PARAM_POINTER_RETURN("imlib_image_get_filename", "image", ctxt_image, + 0); CAST_IMAGE(im, ctxt_image); /* strdup() the returned value if you want to alter it! */ - return (const char *) (im->file); + return (const char *)(im->file); } -DATA32 * +DATA32 * imlib_image_get_data(void) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER_RETURN("imlib_image_get_data", "image", ctxt_image, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_image_get_data", "image", ctxt_image, + NULL); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -543,12 +544,13 @@ imlib_image_get_data(void) return im->data; } -DATA32 * +DATA32 * imlib_image_get_data_for_reading_only(void) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER_RETURN("imlib_image_get_data_for_reading_only", "image", ctxt_image, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_image_get_data_for_reading_only", "image", + ctxt_image, NULL); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -557,10 +559,10 @@ imlib_image_get_data_for_reading_only(void) return im->data; } -void -imlib_image_put_back_data(DATA32 *data) +void +imlib_image_put_back_data(DATA32 * data) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_put_back_data", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_image_put_back_data", "data", data); @@ -570,32 +572,33 @@ imlib_image_put_back_data(DATA32 *data) data = NULL; } -char +char imlib_image_has_alpha(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER_RETURN("imlib_image_has_alpha", "image", ctxt_image, 0); CAST_IMAGE(im, ctxt_image); if (IMAGE_HAS_ALPHA(im)) return 1; - return 0; + return 0; } -void +void imlib_image_set_changes_on_disk(void) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER("imlib_image_set_never_changes_on_disk", "image", ctxt_image); + CHECK_PARAM_POINTER("imlib_image_set_never_changes_on_disk", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); - SET_FLAG(im->flags, F_ALWAYS_CHECK_DISK); + SET_FLAG(im->flags, F_ALWAYS_CHECK_DISK); } -void -imlib_image_get_border(Imlib_Border *border) +void +imlib_image_get_border(Imlib_Border * border) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_get_border", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_image_get_border", "border", border); @@ -606,18 +609,17 @@ imlib_image_get_border(Imlib_Border *border) border->bottom = im->border.bottom; } -void -imlib_image_set_border(Imlib_Border *border) +void +imlib_image_set_border(Imlib_Border * border) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_set_border", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_image_set_border", "border", border); CAST_IMAGE(im, ctxt_image); - if ((im->border.left == border->left) && - (im->border.right == border->right) && - (im->border.top == border->top) && - (im->border.bottom == border->bottom)) + if ((im->border.left == border->left) && (im->border.right == border->right) + && (im->border.top == border->top) + && (im->border.bottom == border->bottom)) return; im->border.left = border->left; im->border.right = border->right; @@ -626,10 +628,10 @@ imlib_image_set_border(Imlib_Border *border) __imlib_DirtyPixmapsForImage(im); } -void +void imlib_image_set_format(const char *format) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_set_format", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_image_set_format", "format", format); @@ -638,128 +640,135 @@ imlib_image_set_format(const char *format) free(im->format); im->format = strdup(format); if (!(im->flags & F_FORMAT_IRRELEVANT)) - { - __imlib_DirtyImage(im); - __imlib_DirtyPixmapsForImage(im); - } + { + __imlib_DirtyImage(im); + __imlib_DirtyPixmapsForImage(im); + } } void imlib_image_set_irrelevant_format(char irrelevant) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER("imlib_image_set_irrelevant_format", "image", ctxt_image); + CHECK_PARAM_POINTER("imlib_image_set_irrelevant_format", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); if (irrelevant) - { - SET_FLAG(im->flags, F_FORMAT_IRRELEVANT); - } + { + SET_FLAG(im->flags, F_FORMAT_IRRELEVANT); + } else - { - UNSET_FLAG(im->flags, F_FORMAT_IRRELEVANT); - } + { + UNSET_FLAG(im->flags, F_FORMAT_IRRELEVANT); + } } void imlib_image_set_irrelevant_border(char irrelevant) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER("imlib_image_set_irrelevant_border", "image", ctxt_image); + CHECK_PARAM_POINTER("imlib_image_set_irrelevant_border", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); if (irrelevant) - { - SET_FLAG(im->flags, F_BORDER_IRRELEVANT); - } + { + SET_FLAG(im->flags, F_BORDER_IRRELEVANT); + } else - { - UNSET_FLAG(im->flags, F_BORDER_IRRELEVANT); - } + { + UNSET_FLAG(im->flags, F_BORDER_IRRELEVANT); + } } void imlib_image_set_irrelevant_alpha(char irrelevant) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_set_irrelevant_alpha", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); if (irrelevant) - { - SET_FLAG(im->flags, F_ALPHA_IRRELEVANT); - } + { + SET_FLAG(im->flags, F_ALPHA_IRRELEVANT); + } else - { - UNSET_FLAG(im->flags, F_ALPHA_IRRELEVANT); - } + { + UNSET_FLAG(im->flags, F_ALPHA_IRRELEVANT); + } } -char * +char * imlib_image_format(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER_RETURN("imlib_image_format", "image", ctxt_image, NULL); CAST_IMAGE(im, ctxt_image); return im->format; } -void +void imlib_image_set_has_alpha(char has_alpha) { - ImlibImage *im; - + ImlibImage *im; + CHECK_PARAM_POINTER("imlib_image_set_has_alpha", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); if (has_alpha) SET_FLAG(im->flags, F_HAS_ALPHA); - else + else UNSET_FLAG(im->flags, F_HAS_ALPHA); } -void -imlib_render_pixmaps_for_whole_image(Pixmap *pixmap_return, - Pixmap *mask_return) +void +imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return, + Pixmap * mask_return) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "image", ctxt_image); - CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "pixmap_return", pixmap_return); - CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "mask_return", mask_return); + CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "image", + ctxt_image); + CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "pixmap_return", + pixmap_return); + CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image", "mask_return", + mask_return); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); if (!(im->data)) return; __imlib_CreatePixmapsForImage(ctxt_display, ctxt_drawable, ctxt_visual, - ctxt_depth, ctxt_colormap, im, pixmap_return, - mask_return, 0, 0, im->w, im->h, im->w, im->h, - 0, ctxt_dither, ctxt_dither_mask, - ctxt_color_modifier); + ctxt_depth, ctxt_colormap, im, pixmap_return, + mask_return, 0, 0, im->w, im->h, im->w, im->h, + 0, ctxt_dither, ctxt_dither_mask, + ctxt_color_modifier); } -void -imlib_render_pixmaps_for_whole_image_at_size(Pixmap *pixmap_return, - Pixmap *mask_return, - int width, int height) +void +imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return, + Pixmap * mask_return, int width, + int height) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", "image", ctxt_image); - CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", "pixmap_return", pixmap_return); - CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", "mask_return", mask_return); + CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", "image", + ctxt_image); + CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", + "pixmap_return", pixmap_return); + CHECK_PARAM_POINTER("imlib_render_pixmaps_for_whole_image_at_size", + "mask_return", mask_return); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); if (!(im->data)) return; - __imlib_CreatePixmapsForImage(ctxt_display, ctxt_drawable, ctxt_visual, - ctxt_depth, ctxt_colormap, im, - pixmap_return, mask_return, 0, 0, im->w, - im->h, width, height, ctxt_anti_alias, - ctxt_dither, ctxt_dither_mask, - ctxt_color_modifier); + __imlib_CreatePixmapsForImage(ctxt_display, ctxt_drawable, ctxt_visual, + ctxt_depth, ctxt_colormap, im, pixmap_return, + mask_return, 0, 0, im->w, im->h, width, height, + ctxt_anti_alias, ctxt_dither, ctxt_dither_mask, + ctxt_color_modifier); } void @@ -768,299 +777,302 @@ imlib_free_pixmap_and_mask(Pixmap pixmap) __imlib_FreePixmap(ctxt_display, pixmap); } -void +void imlib_render_image_on_drawable(int x, int y) { - ImlibImage *im; - + ImlibImage *im; + CHECK_PARAM_POINTER("imlib_render_image_on_drawable", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); if (!(im->data)) return; - __imlib_RenderImage(ctxt_display, im, ctxt_drawable, ctxt_mask, ctxt_visual, - ctxt_colormap, ctxt_depth, 0, 0, im->w, im->h, x, y, - im->w, im->h, 0, ctxt_dither, ctxt_blend, ctxt_dither_mask, - ctxt_color_modifier, ctxt_operation); + __imlib_RenderImage(ctxt_display, im, ctxt_drawable, ctxt_mask, ctxt_visual, + ctxt_colormap, ctxt_depth, 0, 0, im->w, im->h, x, y, + im->w, im->h, 0, ctxt_dither, ctxt_blend, + ctxt_dither_mask, ctxt_color_modifier, ctxt_operation); } void imlib_render_image_on_drawable_at_size(int x, int y, int width, int height) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_size", "image", ctxt_image); + CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_size", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); if (!(im->data)) return; - __imlib_RenderImage(ctxt_display, im, ctxt_drawable, ctxt_mask, ctxt_visual, - ctxt_colormap, ctxt_depth, 0, 0, im->w, im->h, x, y, - width, height, ctxt_anti_alias, ctxt_dither, - ctxt_blend, ctxt_dither_mask, ctxt_color_modifier, ctxt_operation); + __imlib_RenderImage(ctxt_display, im, ctxt_drawable, ctxt_mask, ctxt_visual, + ctxt_colormap, ctxt_depth, 0, 0, im->w, im->h, x, y, + width, height, ctxt_anti_alias, ctxt_dither, ctxt_blend, + ctxt_dither_mask, ctxt_color_modifier, ctxt_operation); } -void +void imlib_render_image_part_on_drawable_at_size(int source_x, int source_y, - int source_width, int source_height, - int x, int y, int width, int height) + int source_width, int source_height, + int x, int y, int width, int height) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER("imlib_render_image_part_on_drawable_at_size", "image", ctxt_image); + CHECK_PARAM_POINTER("imlib_render_image_part_on_drawable_at_size", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); if (!(im->data)) return; - __imlib_RenderImage(ctxt_display, im, ctxt_drawable, 0, ctxt_visual, - ctxt_colormap, ctxt_depth, source_x, source_y, - source_width, source_height, x, y, width, height, - ctxt_anti_alias, ctxt_dither, ctxt_blend, 0, - ctxt_color_modifier, ctxt_operation); + __imlib_RenderImage(ctxt_display, im, ctxt_drawable, 0, ctxt_visual, + ctxt_colormap, ctxt_depth, source_x, source_y, + source_width, source_height, x, y, width, height, + ctxt_anti_alias, ctxt_dither, ctxt_blend, 0, + ctxt_color_modifier, ctxt_operation); } -void -imlib_blend_image_onto_image(Imlib_Image source_image, - char merge_alpha, - int source_x, int source_y, - int source_width, int source_height, - int destination_x, int destination_y, - int destination_width, int destination_height) +void +imlib_blend_image_onto_image(Imlib_Image source_image, char merge_alpha, + int source_x, int source_y, int source_width, + int source_height, int destination_x, + int destination_y, int destination_width, + int destination_height) { - ImlibImage *im_src, *im_dst; - - CHECK_PARAM_POINTER("imlib_blend_image_onto_image", "source_image", source_image); + ImlibImage *im_src, *im_dst; + + CHECK_PARAM_POINTER("imlib_blend_image_onto_image", "source_image", + source_image); CHECK_PARAM_POINTER("imlib_blend_image_onto_image", "image", ctxt_image); CAST_IMAGE(im_src, source_image); CAST_IMAGE(im_dst, ctxt_image); __imlib_DirtyImage(im_dst); __imlib_DirtyPixmapsForImage(im_dst); /* FIXME: hack to get around infinite loops for scaling down too far */ - if ((abs(destination_width) < (source_width >> 7)) || - (abs(destination_height) < (source_height >> 7))) - __imlib_BlendImageToImage(im_src, im_dst, 0, ctxt_blend, - merge_alpha, source_x, source_y, source_width, - source_height, destination_x, destination_y, - destination_width, destination_height, - ctxt_color_modifier, ctxt_operation); + if ((abs(destination_width) < (source_width >> 7)) + || (abs(destination_height) < (source_height >> 7))) + __imlib_BlendImageToImage(im_src, im_dst, 0, ctxt_blend, merge_alpha, + source_x, source_y, source_width, source_height, + destination_x, destination_y, destination_width, + destination_height, ctxt_color_modifier, + ctxt_operation); else - __imlib_BlendImageToImage(im_src, im_dst, ctxt_anti_alias, ctxt_blend, - merge_alpha, source_x, source_y, source_width, - source_height, destination_x, destination_y, - destination_width, destination_height, - ctxt_color_modifier, ctxt_operation); + __imlib_BlendImageToImage(im_src, im_dst, ctxt_anti_alias, ctxt_blend, + merge_alpha, source_x, source_y, source_width, + source_height, destination_x, destination_y, + destination_width, destination_height, + ctxt_color_modifier, ctxt_operation); } -Imlib_Image -imlib_create_image(int width, int height) +Imlib_Image imlib_create_image(int width, int height) { - DATA32 *data; - + DATA32 *data; + if ((width <= 0) || (height <= 0)) return NULL; data = malloc(width * height * sizeof(DATA32)); if (data) - return (Imlib_Image)__imlib_CreateImage(width, height, data); + return (Imlib_Image) __imlib_CreateImage(width, height, data); return NULL; } -Imlib_Image -imlib_create_image_using_data(int width, int height, - DATA32 *data) +Imlib_Image imlib_create_image_using_data(int width, int height, DATA32 * data) { - ImlibImage *im; + ImlibImage *im; - CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_data", "data", data, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_data", "data", data, + NULL); if ((width <= 0) || (height <= 0)) return NULL; im = __imlib_CreateImage(width, height, data); if (im) SET_FLAG(im->flags, F_DONT_FREE_DATA); - return (Imlib_Image)im; + return (Imlib_Image) im; } -Imlib_Image -imlib_create_image_using_copied_data(int width, int height, - DATA32 *data) +Imlib_Image imlib_create_image_using_copied_data(int width, int height, + DATA32 * data) { - ImlibImage *im; - - CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_copied_data", "data", data, NULL); + ImlibImage *im; + + CHECK_PARAM_POINTER_RETURN("imlib_create_image_using_copied_data", "data", + data, NULL); if ((width <= 0) || (height <= 0)) return NULL; im = __imlib_CreateImage(width, height, NULL); if (!im) return NULL; - im->data = malloc(width * height *sizeof(DATA32)); + im->data = malloc(width * height * sizeof(DATA32)); if (data) - { - memcpy(im->data, data, width * height *sizeof(DATA32)); - return (Imlib_Image)im; - } + { + memcpy(im->data, data, width * height * sizeof(DATA32)); + return (Imlib_Image) im; + } else __imlib_FreeImage(im); return NULL; } -Imlib_Image -imlib_create_image_from_drawable(Pixmap mask, - int x, int y, - int width, int height, char need_to_grab_x) +Imlib_Image imlib_create_image_from_drawable(Pixmap mask, int x, int y, + int width, int height, + char need_to_grab_x) { - ImlibImage *im; - char domask = 0; - + ImlibImage *im; + char domask = 0; + if (mask) domask = 1; im = __imlib_CreateImage(width, height, NULL); im->data = malloc(width * height * sizeof(DATA32)); - __imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctxt_display, - ctxt_drawable, mask, ctxt_visual, ctxt_colormap, - ctxt_depth, x, y, width, height, domask, - need_to_grab_x); - return (Imlib_Image)im; + __imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctxt_display, + ctxt_drawable, mask, ctxt_visual, ctxt_colormap, + ctxt_depth, x, y, width, height, domask, + need_to_grab_x); + return (Imlib_Image) im; } -Imlib_Image -imlib_create_scaled_image_from_drawable(Pixmap mask, - int source_x, int source_y, - int source_width, int source_height, - int destination_width, int destination_height, - char need_to_grab_x, - char get_mask_from_shape) +Imlib_Image imlib_create_scaled_image_from_drawable(Pixmap mask, int source_x, + int source_y, + int source_width, + int source_height, + int destination_width, + int destination_height, + char need_to_grab_x, + char get_mask_from_shape) { - ImlibImage *im; - char domask = 0, tmpmask = 0; - int x, xx; - XGCValues gcv; - GC gc = 0, mgc = 0; - Pixmap p, m; - + ImlibImage *im; + char domask = 0, tmpmask = 0; + int x, xx; + XGCValues gcv; + GC gc = 0, mgc = 0; + Pixmap p, m; + if ((mask) || (get_mask_from_shape)) domask = 1; - p = XCreatePixmap(ctxt_display, ctxt_drawable, destination_width, - source_height, ctxt_depth); + p = + XCreatePixmap(ctxt_display, ctxt_drawable, destination_width, + source_height, ctxt_depth); gcv.foreground = 0; gcv.subwindow_mode = IncludeInferiors; if (domask) - { - m = XCreatePixmap(ctxt_display, ctxt_drawable, destination_width, - source_height, 1); - mgc = XCreateGC(ctxt_display, m, GCForeground, &gcv); - } + { + m = + XCreatePixmap(ctxt_display, ctxt_drawable, destination_width, + source_height, 1); + mgc = XCreateGC(ctxt_display, m, GCForeground, &gcv); + } else m = None; gc = XCreateGC(ctxt_display, ctxt_drawable, GCSubwindowMode, &gcv); if ((domask) && (!mask)) - { - XRectangle *rect; - int rect_num, rect_ord; - - tmpmask = 1; - mask = XCreatePixmap(ctxt_display, ctxt_drawable, source_width, - source_height, 1); - rect = XShapeGetRectangles(ctxt_display, ctxt_drawable, ShapeBounding, - &rect_num, &rect_ord); - XFillRectangle(ctxt_display, mask, mgc, 0, 0, source_width, - source_height); - if (rect) - { - XSetForeground(ctxt_display, mgc, 1); - for (x = 0; x < rect_num; x++) - XFillRectangle(ctxt_display, mask, mgc, rect[x].x, rect[x].y, - rect[x].width, rect[x].height); - XFree(rect); - } - /* build mask from window shape rects */ - } + { + XRectangle *rect; + int rect_num, rect_ord; + + tmpmask = 1; + mask = + XCreatePixmap(ctxt_display, ctxt_drawable, source_width, source_height, + 1); + rect = + XShapeGetRectangles(ctxt_display, ctxt_drawable, ShapeBounding, + &rect_num, &rect_ord); + XFillRectangle(ctxt_display, mask, mgc, 0, 0, source_width, + source_height); + if (rect) + { + XSetForeground(ctxt_display, mgc, 1); + for (x = 0; x < rect_num; x++) + XFillRectangle(ctxt_display, mask, mgc, rect[x].x, rect[x].y, + rect[x].width, rect[x].height); + XFree(rect); + } + /* build mask from window shape rects */ + } for (x = 0; x < destination_width; x++) - { - xx = (source_width * x) / destination_width; - XCopyArea(ctxt_display, ctxt_drawable, p, gc, source_x + xx, 0, 1, - source_height, xx, 0); - if (m != None) - XCopyArea(ctxt_display, mask, m, mgc, xx, 0, 1, source_height, - xx, 0); - } + { + xx = (source_width * x) / destination_width; + XCopyArea(ctxt_display, ctxt_drawable, p, gc, source_x + xx, 0, 1, + source_height, xx, 0); + if (m != None) + XCopyArea(ctxt_display, mask, m, mgc, xx, 0, 1, source_height, xx, 0); + } for (x = 0; x < destination_height; x++) - { - xx = (source_height * x) / destination_height; - XCopyArea(ctxt_display, ctxt_drawable, p, gc, 0, source_y + xx, - destination_width, 1, 0, xx); - if (m != None) - XCopyArea(ctxt_display, mask, m, mgc, 0, source_y + xx, - destination_width, 1, 0, xx); - } + { + xx = (source_height * x) / destination_height; + XCopyArea(ctxt_display, ctxt_drawable, p, gc, 0, source_y + xx, + destination_width, 1, 0, xx); + if (m != None) + XCopyArea(ctxt_display, mask, m, mgc, 0, source_y + xx, + destination_width, 1, 0, xx); + } im = __imlib_CreateImage(destination_width, destination_height, NULL); im->data = malloc(destination_width * destination_height * sizeof(DATA32)); - __imlib_GrabDrawableToRGBA(im->data, 0, 0, destination_width, - destination_height, ctxt_display, p, m, - ctxt_visual, ctxt_colormap, ctxt_depth, 0, 0, - source_width, source_height, domask, - need_to_grab_x); + __imlib_GrabDrawableToRGBA(im->data, 0, 0, destination_width, + destination_height, ctxt_display, p, m, + ctxt_visual, ctxt_colormap, ctxt_depth, 0, 0, + source_width, source_height, domask, + need_to_grab_x); XFreePixmap(ctxt_display, p); if (m != None) - { - XFreeGC(ctxt_display, mgc); - XFreePixmap(ctxt_display, m); - if (tmpmask) - XFreePixmap(ctxt_display, mask); - } + { + XFreeGC(ctxt_display, mgc); + XFreePixmap(ctxt_display, m); + if (tmpmask) + XFreePixmap(ctxt_display, mask); + } XFreeGC(ctxt_display, gc); - return (Imlib_Image)im; + return (Imlib_Image) im; } char -imlib_copy_drawable_to_image(Pixmap mask, int x, int y, - int width, int height, - int destination_x, int destination_y, - char need_to_grab_x) +imlib_copy_drawable_to_image(Pixmap mask, int x, int y, int width, int height, + int destination_x, int destination_y, + char need_to_grab_x) { - ImlibImage *im; - char domask = 0; - int pre_adj; - - CHECK_PARAM_POINTER_RETURN("imlib_copy_drawable_to_image", "image", ctxt_image, 0); + ImlibImage *im; + char domask = 0; + int pre_adj; + + CHECK_PARAM_POINTER_RETURN("imlib_copy_drawable_to_image", "image", + ctxt_image, 0); if (mask) - domask = 1; + domask = 1; CAST_IMAGE(im, ctxt_image); pre_adj = 0; if (x < 0) - { - width += x; - pre_adj = x; - x = 0; - } + { + width += x; + pre_adj = x; + x = 0; + } if (width < 0) width = 0; if (destination_x < 0) - { - width += destination_x; - x -= destination_x - pre_adj; - destination_x = 0; - } + { + width += destination_x; + x -= destination_x - pre_adj; + destination_x = 0; + } if ((destination_x + width) >= im->w) width = im->w - destination_x; pre_adj = 0; if (y < 0) - { - height += y; - pre_adj = y; - y = 0; - } + { + height += y; + pre_adj = y; + y = 0; + } if (height < 0) height = 0; if (destination_y < 0) - { - height += destination_y; - y -= destination_y - pre_adj; - destination_y = 0; - } + { + height += destination_y; + y -= destination_y - pre_adj; + destination_y = 0; + } if ((destination_y + height) >= im->h) height = im->h - destination_y; @@ -1069,17 +1081,15 @@ imlib_copy_drawable_to_image(Pixmap mask, int x, int y, __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); return __imlib_GrabDrawableToRGBA(im->data, destination_x, destination_y, - im->w, im->h, ctxt_display, - ctxt_drawable, mask, ctxt_visual, - ctxt_colormap, ctxt_depth, - x, y, width, height, - domask, need_to_grab_x); + im->w, im->h, ctxt_display, ctxt_drawable, + mask, ctxt_visual, ctxt_colormap, + ctxt_depth, x, y, width, height, domask, + need_to_grab_x); } -Imlib_Image -imlib_clone_image(void) +Imlib_Image imlib_clone_image(void) { - ImlibImage *im, *im_old; + ImlibImage *im, *im_old; CHECK_PARAM_POINTER_RETURN("imlib_clone_image", "image", ctxt_image, NULL); CAST_IMAGE(im_old, ctxt_image); @@ -1090,13 +1100,13 @@ imlib_clone_image(void) im = __imlib_CreateImage(im_old->w, im_old->h, NULL); if (!(im)) return NULL; - im->data = malloc(im->w * im->h *sizeof(DATA32)); + im->data = malloc(im->w * im->h * sizeof(DATA32)); if (!(im->data)) - { - __imlib_FreeImage(im); - return NULL; - } - memcpy(im->data, im_old->data, im->w * im->h *sizeof(DATA32)); + { + __imlib_FreeImage(im); + return NULL; + } + memcpy(im->data, im_old->data, im->w * im->h * sizeof(DATA32)); im->flags = im_old->flags; SET_FLAG(im->flags, F_UNCACHEABLE); SET_FLAG(im->flags, F_UNCACHEABLE); @@ -1104,144 +1114,144 @@ imlib_clone_image(void) im->border = im_old->border; im->loader = im_old->loader; if (im_old->format) - { - im->format = malloc(strlen(im_old->format) + 1); - strcpy(im->format, im_old->format); - } + { + im->format = malloc(strlen(im_old->format) + 1); + strcpy(im->format, im_old->format); + } if (im_old->file) - { - im->file = malloc(strlen(im_old->file) + 1); - strcpy(im->file, im_old->file); - } - return (Imlib_Image)im; + { + im->file = malloc(strlen(im_old->file) + 1); + strcpy(im->file, im_old->file); + } + return (Imlib_Image) im; } -Imlib_Image -imlib_create_cropped_image(int x, int y, int width, int height) +Imlib_Image imlib_create_cropped_image(int x, int y, int width, int height) { - ImlibImage *im, *im_old; + ImlibImage *im, *im_old; - CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_image", "image", ctxt_image, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_image", "image", ctxt_image, + NULL); CAST_IMAGE(im_old, ctxt_image); if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load)) im_old->loader->load(im_old, NULL, 0, 1); if (!(im_old->data)) return NULL; im = __imlib_CreateImage(abs(width), abs(height), NULL); - im->data = malloc(abs(width * height) *sizeof(DATA32)); + im->data = malloc(abs(width * height) * sizeof(DATA32)); if (!(im->data)) - { - __imlib_FreeImage(im); - return NULL; - } - __imlib_BlendImageToImage(im_old, im, 0, 0, 0, - x, y, abs(width), abs(height), - 0, 0, width, height, NULL, IMLIB_OP_COPY); - return (Imlib_Image)im; + { + __imlib_FreeImage(im); + return NULL; + } + __imlib_BlendImageToImage(im_old, im, 0, 0, 0, x, y, abs(width), abs(height), + 0, 0, width, height, NULL, IMLIB_OP_COPY); + return (Imlib_Image) im; } -Imlib_Image -imlib_create_cropped_scaled_image(int source_x, int source_y, int source_width, - int source_height, int destination_width, - int destination_height) +Imlib_Image imlib_create_cropped_scaled_image(int source_x, int source_y, + int source_width, + int source_height, + int destination_width, + int destination_height) { - ImlibImage *im, *im_old; - - CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_scaled_image", "image", ctxt_image, NULL); + ImlibImage *im, *im_old; + + CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_scaled_image", "image", + ctxt_image, NULL); CAST_IMAGE(im_old, ctxt_image); if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load)) im_old->loader->load(im_old, NULL, 0, 1); if (!(im_old->data)) return NULL; - im = __imlib_CreateImage(abs(destination_width), abs(destination_height), NULL); - im->data = malloc(abs(destination_width * destination_height) *sizeof(DATA32)); + im = + __imlib_CreateImage(abs(destination_width), abs(destination_height), + NULL); + im->data = + malloc(abs(destination_width * destination_height) * sizeof(DATA32)); if (!(im->data)) - { - __imlib_FreeImage(im); - return NULL; - } + { + __imlib_FreeImage(im); + return NULL; + } if (IMAGE_HAS_ALPHA(im_old)) - { - SET_FLAG(im->flags, F_HAS_ALPHA); - __imlib_BlendImageToImage(im_old, im, ctxt_anti_alias, 0, 1, - source_x, source_y, source_width, source_height, - 0, 0, destination_width, destination_height, - NULL, IMLIB_OP_COPY); - } + { + SET_FLAG(im->flags, F_HAS_ALPHA); + __imlib_BlendImageToImage(im_old, im, ctxt_anti_alias, 0, 1, source_x, + source_y, source_width, source_height, 0, 0, + destination_width, destination_height, NULL, + IMLIB_OP_COPY); + } else - { - __imlib_BlendImageToImage(im_old, im, ctxt_anti_alias, 0, 0, - source_x, source_y, source_width, source_height, - 0, 0, destination_width, destination_height, - NULL, IMLIB_OP_COPY); - } - return (Imlib_Image)im; + { + __imlib_BlendImageToImage(im_old, im, ctxt_anti_alias, 0, 0, source_x, + source_y, source_width, source_height, 0, 0, + destination_width, destination_height, NULL, + IMLIB_OP_COPY); + } + return (Imlib_Image) im; } -Imlib_Updates -imlib_updates_clone(Imlib_Updates updates) +Imlib_Updates imlib_updates_clone(Imlib_Updates updates) { - ImlibUpdate *u; - - u = (ImlibUpdate *)updates; - return (Imlib_Updates)__imlib_DupUpdates(u); + ImlibUpdate *u; + + u = (ImlibUpdate *) updates; + return (Imlib_Updates) __imlib_DupUpdates(u); } -Imlib_Updates -imlib_update_append_rect(Imlib_Updates updates, int x, int y, int w, int h) +Imlib_Updates imlib_update_append_rect(Imlib_Updates updates, int x, int y, + int w, int h) { - ImlibUpdate *u; - - u = (ImlibUpdate *)updates; - return (Imlib_Updates)__imlib_AddUpdate(u, x, y, w, h); + ImlibUpdate *u; + + u = (ImlibUpdate *) updates; + return (Imlib_Updates) __imlib_AddUpdate(u, x, y, w, h); } -Imlib_Updates -imlib_updates_merge(Imlib_Updates updates, int w, int h) +Imlib_Updates imlib_updates_merge(Imlib_Updates updates, int w, int h) { - ImlibUpdate *u; - - u = (ImlibUpdate *)updates; - return (Imlib_Updates)__imlib_MergeUpdate(u, w, h, 0); + ImlibUpdate *u; + + u = (ImlibUpdate *) updates; + return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 0); } -Imlib_Updates -imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, int h) +Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, + int h) { - ImlibUpdate *u; - - u = (ImlibUpdate *)updates; - return (Imlib_Updates)__imlib_MergeUpdate(u, w, h, 3); + ImlibUpdate *u; + + u = (ImlibUpdate *) updates; + return (Imlib_Updates) __imlib_MergeUpdate(u, w, h, 3); } -void +void imlib_updates_free(Imlib_Updates updates) { - ImlibUpdate *u; - - u = (ImlibUpdate *)updates; + ImlibUpdate *u; + + u = (ImlibUpdate *) updates; __imlib_FreeUpdates(u); } -Imlib_Updates -imlib_updates_get_next(Imlib_Updates updates) +Imlib_Updates imlib_updates_get_next(Imlib_Updates updates) { - ImlibUpdate *u; - - u = (ImlibUpdate *)updates; - return (Imlib_Updates)(u->next); + ImlibUpdate *u; + + u = (ImlibUpdate *) updates; + return (Imlib_Updates) (u->next); } - -void -imlib_updates_get_coordinates(Imlib_Updates updates, - int *x_return, int *y_return, - int *width_return, int *height_return) +void +imlib_updates_get_coordinates(Imlib_Updates updates, int *x_return, + int *y_return, int *width_return, + int *height_return) { - ImlibUpdate *u; - + ImlibUpdate *u; + CHECK_PARAM_POINTER("imlib_updates_get_coordinates", "updates", updates); - u = (ImlibUpdate *)updates; + u = (ImlibUpdate *) updates; if (x_return) *x_return = u->x; if (y_return) @@ -1252,30 +1262,30 @@ imlib_updates_get_coordinates(Imlib_Updates updates, *height_return = u->h; } -void -imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y, - int width, int height) +void +imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y, int width, + int height) { - ImlibUpdate *u; - + ImlibUpdate *u; + CHECK_PARAM_POINTER("imlib_updates_set_coordinates", "updates", updates); - u = (ImlibUpdate *)updates; + u = (ImlibUpdate *) updates; u->x = x; u->y = y; u->w = width; u->h = height; } -void -imlib_render_image_updates_on_drawable(Imlib_Updates updates, - int x, int y) +void +imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x, int y) { - ImlibUpdate *u; - ImlibImage *im; - - CHECK_PARAM_POINTER("imlib_render_image_updates_on_drawable", "image", ctxt_image); + ImlibUpdate *u; + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_render_image_updates_on_drawable", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); - u = (ImlibUpdate *)updates; + u = (ImlibUpdate *) updates; if (!updates) return; if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -1284,49 +1294,47 @@ imlib_render_image_updates_on_drawable(Imlib_Updates updates, return; __imlib_SetMaxXImageCount(ctxt_display, 10); for (; u; u = u->next) - { - __imlib_RenderImage(ctxt_display, im, ctxt_drawable, 0, ctxt_visual, - ctxt_colormap, ctxt_depth, u->x, u->y, u->w, u->h, - x + u->x, y + u->y, u->w, u->h, 0, ctxt_dither, - 0, 0, ctxt_color_modifier, OP_COPY); - } + { + __imlib_RenderImage(ctxt_display, im, ctxt_drawable, 0, ctxt_visual, + ctxt_colormap, ctxt_depth, u->x, u->y, u->w, u->h, + x + u->x, y + u->y, u->w, u->h, 0, ctxt_dither, 0, 0, + ctxt_color_modifier, OP_COPY); + } __imlib_SetMaxXImageCount(ctxt_display, 0); } -Imlib_Updates -imlib_updates_init(void) +Imlib_Updates imlib_updates_init(void) { - return (Imlib_Updates)NULL; + return (Imlib_Updates) NULL; } -Imlib_Updates -imlib_updates_append_updates(Imlib_Updates updates, - Imlib_Updates appended_updates) +Imlib_Updates imlib_updates_append_updates(Imlib_Updates updates, + Imlib_Updates appended_updates) { - ImlibUpdate *u, *uu; + ImlibUpdate *u, *uu; - u = (ImlibUpdate *)updates; - uu = (ImlibUpdate *)appended_updates; + u = (ImlibUpdate *) updates; + uu = (ImlibUpdate *) appended_updates; if (!uu) - return (Imlib_Updates)u; + return (Imlib_Updates) u; if (!u) - return (Imlib_Updates)uu; + return (Imlib_Updates) uu; while (u) - { - if (!(u->next)) - { - u->next = uu; - return updates; - } - u = u->next; - } - return (Imlib_Updates)u; + { + if (!(u->next)) + { + u->next = uu; + return updates; + } + u = u->next; + } + return (Imlib_Updates) u; } -void +void imlib_image_flip_horizontal(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_flip_horizontal", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1339,10 +1347,10 @@ imlib_image_flip_horizontal(void) __imlib_FlipImageHoriz(im); } -void +void imlib_image_flip_vertical(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_flip_vertical", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1355,10 +1363,10 @@ imlib_image_flip_vertical(void) __imlib_FlipImageVert(im); } -void +void imlib_image_flip_diagonal(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_flip_diagonal", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1374,7 +1382,7 @@ imlib_image_flip_diagonal(void) void imlib_image_orientate(int orientation) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_orientate", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1384,38 +1392,39 @@ imlib_image_orientate(int orientation) return; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - switch (orientation) { - default: - case 0: - break; - case 1: - __imlib_FlipImageDiagonal(im, 1); - break; - case 2: - __imlib_FlipImageBoth(im); - break; - case 3: - __imlib_FlipImageDiagonal(im, 2); - break; - case 4: - __imlib_FlipImageHoriz(im); - break; - case 5: - __imlib_FlipImageDiagonal(im, 3); - break; - case 6: - __imlib_FlipImageVert(im); - break; - case 7: - __imlib_FlipImageDiagonal(im, 0); - break; + switch (orientation) + { + default: + case 0: + break; + case 1: + __imlib_FlipImageDiagonal(im, 1); + break; + case 2: + __imlib_FlipImageBoth(im); + break; + case 3: + __imlib_FlipImageDiagonal(im, 2); + break; + case 4: + __imlib_FlipImageHoriz(im); + break; + case 5: + __imlib_FlipImageDiagonal(im, 3); + break; + case 6: + __imlib_FlipImageVert(im); + break; + case 7: + __imlib_FlipImageDiagonal(im, 0); + break; } } -void +void imlib_image_blur(int radius) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_blur", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1428,10 +1437,10 @@ imlib_image_blur(int radius) __imlib_BlurImage(im, radius); } -void +void imlib_image_sharpen(int radius) { - ImlibImage *im; + ImlibImage *im; CAST_IMAGE(im, ctxt_image); CHECK_PARAM_POINTER("imlib_image_sharpen", "image", ctxt_image); @@ -1444,10 +1453,10 @@ imlib_image_sharpen(int radius) __imlib_SharpenImage(im, radius); } -void +void imlib_image_tile_horizontal(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_tile_horizontal", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1460,10 +1469,10 @@ imlib_image_tile_horizontal(void) __imlib_TileImageHoriz(im); } -void +void imlib_image_tile_vertical(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_tile_vertical", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1476,10 +1485,10 @@ imlib_image_tile_vertical(void) __imlib_TileImageVert(im); } -void +void imlib_image_tile(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_tile", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); @@ -1493,13 +1502,12 @@ imlib_image_tile(void) __imlib_TileImageVert(im); } -Imlib_Font -imlib_load_font(const char *font_name) +Imlib_Font imlib_load_font(const char *font_name) { - return (Imlib_Font)__imlib_load_font(font_name); + return (Imlib_Font) __imlib_load_font(font_name); } -void +void imlib_free_font(void) { CHECK_PARAM_POINTER("imlib_free_font", "font", ctxt_font); @@ -1507,301 +1515,323 @@ imlib_free_font(void) ctxt_font = NULL; } -void +void imlib_text_draw(int x, int y, const char *text) { - ImlibImage *im; - + ImlibImage *im; + CHECK_PARAM_POINTER("imlib_text_draw", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_text_draw", "text", text); CAST_IMAGE(im, ctxt_image); __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - __imlib_render_str(im, ctxt_font, x, y, text, (DATA8)ctxt_color.red, - (DATA8)ctxt_color.green, (DATA8)ctxt_color.blue, - (DATA8)ctxt_color.alpha, (char)ctxt_direction, - ctxt_angle, NULL, NULL, 0, NULL, NULL, - ctxt_operation); + __imlib_render_str(im, ctxt_font, x, y, text, (DATA8) ctxt_color.red, + (DATA8) ctxt_color.green, (DATA8) ctxt_color.blue, + (DATA8) ctxt_color.alpha, (char)ctxt_direction, + ctxt_angle, NULL, NULL, 0, NULL, NULL, ctxt_operation); } -void +void imlib_text_draw_with_return_metrics(int x, int y, const char *text, - int *width_return, int *height_return, - int *horizontal_advance_return, - int *vertical_advance_return) + int *width_return, int *height_return, + int *horizontal_advance_return, + int *vertical_advance_return) { - ImlibImage *im; - ImlibFont *fn; - - CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "font", ctxt_font); - CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "image", ctxt_image); + ImlibImage *im; + ImlibFont *fn; + + CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "font", + ctxt_font); + CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "image", + ctxt_image); CHECK_PARAM_POINTER("imlib_text_draw_with_return_metrics", "text", text); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); if (!(im->data)) return; - fn = (ImlibFont *)ctxt_font; + fn = (ImlibFont *) ctxt_font; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - __imlib_render_str(im, fn, x, y, text, (DATA8)ctxt_color.red, - (DATA8)ctxt_color.green, (DATA8)ctxt_color.blue, - (DATA8)ctxt_color.alpha, (char)ctxt_direction, - ctxt_angle, width_return, height_return, 0, - horizontal_advance_return, vertical_advance_return, - ctxt_operation); + __imlib_render_str(im, fn, x, y, text, (DATA8) ctxt_color.red, + (DATA8) ctxt_color.green, (DATA8) ctxt_color.blue, + (DATA8) ctxt_color.alpha, (char)ctxt_direction, + ctxt_angle, width_return, height_return, 0, + horizontal_advance_return, vertical_advance_return, + ctxt_operation); } -void +void imlib_get_text_size(const char *text, int *width_return, int *height_return) { - ImlibFont *fn; - int w, h; - + ImlibFont *fn; + int w, h; + CHECK_PARAM_POINTER("imlib_get_text_size", "font", ctxt_font); CHECK_PARAM_POINTER("imlib_get_text_size", "text", text); - fn = (ImlibFont *)ctxt_font; + fn = (ImlibFont *) ctxt_font; __imlib_calc_size(fn, &w, &h, text); - switch(ctxt_direction) - { + switch (ctxt_direction) + { case IMLIB_TEXT_TO_RIGHT: case IMLIB_TEXT_TO_LEFT: - if (width_return) - *width_return = w; - if (height_return) - *height_return = h; - break; + if (width_return) + *width_return = w; + if (height_return) + *height_return = h; + break; case IMLIB_TEXT_TO_DOWN: case IMLIB_TEXT_TO_UP: - if (width_return) - *width_return = h; - if (height_return) - *height_return = w; - break; + if (width_return) + *width_return = h; + if (height_return) + *height_return = w; + break; case IMLIB_TEXT_TO_ANGLE: - if (width_return || height_return) - { - double sa, ca; - sa = sin(ctxt_angle); - ca = cos(ctxt_angle); + if (width_return || height_return) + { + double sa, ca; - if (width_return) { - double x1, x2, xt; - x1 = x2 = 0.0; - xt = ca * w; - if (xt < x1) x1 = xt; - if (xt > x2) x2 = xt; - xt = -(sa * h); - if (xt < x1) x1 = xt; - if (xt > x2) x2 = xt; - xt = ca * w - sa * h; - if (xt < x1) x1 = xt; - if (xt > x2) x2 = xt; - *width_return = (int)(x2 - x1); - } - if (height_return) { - double y1, y2, yt; - y1 = y2 = 0.0; - yt = sa * w; - if (yt < y1) y1 = yt; - if (yt > y2) y2 = yt; - yt = ca * h; - if (yt < y1) y1 = yt; - if (yt > y2) y2 = yt; - yt = sa * w + ca * h; - if (yt < y1) y1 = yt; - if (yt > y2) y2 = yt; - *height_return = (int)(y2 - y1); - } - } - break; + sa = sin(ctxt_angle); + ca = cos(ctxt_angle); + + if (width_return) + { + double x1, x2, xt; + + x1 = x2 = 0.0; + xt = ca * w; + if (xt < x1) + x1 = xt; + if (xt > x2) + x2 = xt; + xt = -(sa * h); + if (xt < x1) + x1 = xt; + if (xt > x2) + x2 = xt; + xt = ca * w - sa * h; + if (xt < x1) + x1 = xt; + if (xt > x2) + x2 = xt; + *width_return = (int)(x2 - x1); + } + if (height_return) + { + double y1, y2, yt; + + y1 = y2 = 0.0; + yt = sa * w; + if (yt < y1) + y1 = yt; + if (yt > y2) + y2 = yt; + yt = ca * h; + if (yt < y1) + y1 = yt; + if (yt > y2) + y2 = yt; + yt = sa * w + ca * h; + if (yt < y1) + y1 = yt; + if (yt > y2) + y2 = yt; + *height_return = (int)(y2 - y1); + } + } + break; default: - break; - } + break; + } } -void +void imlib_add_path_to_font_path(const char *path) { CHECK_PARAM_POINTER("imlib_add_path_to_font_path", "path", path); __imlib_add_font_path(path); } -void +void imlib_remove_path_from_font_path(const char *path) { CHECK_PARAM_POINTER("imlib_remove_path_from_font_path", "path", path); __imlib_del_font_path(path); } -char ** +char ** imlib_list_font_path(int *number_return) { - CHECK_PARAM_POINTER_RETURN("imlib_list_font_path", "number_return", number_return, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_list_font_path", "number_return", + number_return, NULL); return __imlib_list_font_path(number_return); } int imlib_text_get_index_and_location(const char *text, int x, int y, - int *char_x_return, int *char_y_return, - int *char_width_return, - int *char_height_return) + int *char_x_return, int *char_y_return, + int *char_width_return, + int *char_height_return) { - ImlibFont *fn; - int w, h, cx, cy, cw, ch, cp, xx, yy; - - CHECK_PARAM_POINTER_RETURN("imlib_text_get_index_and_location", "font", ctxt_font, -1); - CHECK_PARAM_POINTER_RETURN("imlib_text_get_index_and_location", "text", text, -1); - fn = (ImlibFont *)ctxt_font; - switch(ctxt_direction) - { + ImlibFont *fn; + int w, h, cx, cy, cw, ch, cp, xx, yy; + + CHECK_PARAM_POINTER_RETURN("imlib_text_get_index_and_location", "font", + ctxt_font, -1); + CHECK_PARAM_POINTER_RETURN("imlib_text_get_index_and_location", "text", text, + -1); + fn = (ImlibFont *) ctxt_font; + switch (ctxt_direction) + { case IMLIB_TEXT_TO_RIGHT: - cp = __imlib_char_pos(fn, text, x, y, &cx, &cy, &cw, &ch); - if (char_x_return) - *char_x_return = cx; - if (char_y_return) - *char_y_return = cy; - if (char_width_return) - *char_width_return = cw; - if (char_height_return) - *char_height_return = ch; - return cp; - break; + cp = __imlib_char_pos(fn, text, x, y, &cx, &cy, &cw, &ch); + if (char_x_return) + *char_x_return = cx; + if (char_y_return) + *char_y_return = cy; + if (char_width_return) + *char_width_return = cw; + if (char_height_return) + *char_height_return = ch; + return cp; + break; case IMLIB_TEXT_TO_LEFT: - __imlib_calc_size(fn, &w, &h, text); - xx = w - x; - yy = h - y; - cp = __imlib_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch); - cx = 1 + w - cx - cw; - if (char_x_return) - *char_x_return = cx; - if (char_y_return) - *char_y_return = cy; - if (char_width_return) - *char_width_return = cw; - if (char_height_return) - *char_height_return = ch; - return cp; - break; + __imlib_calc_size(fn, &w, &h, text); + xx = w - x; + yy = h - y; + cp = __imlib_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch); + cx = 1 + w - cx - cw; + if (char_x_return) + *char_x_return = cx; + if (char_y_return) + *char_y_return = cy; + if (char_width_return) + *char_width_return = cw; + if (char_height_return) + *char_height_return = ch; + return cp; + break; case IMLIB_TEXT_TO_DOWN: - __imlib_calc_size(fn, &w, &h, text); - xx = h - y; - yy = x; - cp = __imlib_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch); - if (char_x_return) - *char_x_return = cy; - if (char_y_return) - *char_y_return = cx; - if (char_width_return) - *char_width_return = ch; - if (char_height_return) - *char_height_return = cw; - return cp; - break; + __imlib_calc_size(fn, &w, &h, text); + xx = h - y; + yy = x; + cp = __imlib_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch); + if (char_x_return) + *char_x_return = cy; + if (char_y_return) + *char_y_return = cx; + if (char_width_return) + *char_width_return = ch; + if (char_height_return) + *char_height_return = cw; + return cp; + break; case IMLIB_TEXT_TO_UP: - __imlib_calc_size(fn, &w, &h, text); - xx = w - y; - yy = x; - cp = __imlib_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch); - cy = 1 + h - cy - ch; - if (char_x_return) - *char_x_return = cy; - if (char_y_return) - *char_y_return = cx; - if (char_width_return) - *char_width_return = ch; - if (char_height_return) - *char_height_return = cw; - return cp; - break; + __imlib_calc_size(fn, &w, &h, text); + xx = w - y; + yy = x; + cp = __imlib_char_pos(fn, text, xx, yy, &cx, &cy, &cw, &ch); + cy = 1 + h - cy - ch; + if (char_x_return) + *char_x_return = cy; + if (char_y_return) + *char_y_return = cx; + if (char_width_return) + *char_width_return = ch; + if (char_height_return) + *char_height_return = cw; + return cp; + break; default: - return -1; - break; - } + return -1; + break; + } return -1; } void imlib_text_get_location_at_index(const char *text, int index, - int *char_x_return, int *char_y_return, - int *char_width_return, - int *char_height_return) + int *char_x_return, int *char_y_return, + int *char_width_return, + int *char_height_return) { - ImlibFont *fn; - int cx, cy, cw, ch, w, h; - + ImlibFont *fn; + int cx, cy, cw, ch, w, h; + CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "font", ctxt_font); CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "text", text); - fn = (ImlibFont *)ctxt_font; - switch(ctxt_direction) - { + fn = (ImlibFont *) ctxt_font; + switch (ctxt_direction) + { case IMLIB_TEXT_TO_RIGHT: - __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); - if (char_x_return) - *char_x_return = cx; - if (char_y_return) - *char_y_return = cy; - if (char_width_return) - *char_width_return = cw; - if (char_height_return) - *char_height_return = ch; - return; - break; + __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); + if (char_x_return) + *char_x_return = cx; + if (char_y_return) + *char_y_return = cy; + if (char_width_return) + *char_width_return = cw; + if (char_height_return) + *char_height_return = ch; + return; + break; case IMLIB_TEXT_TO_LEFT: - __imlib_calc_size(fn, &w, &h, text); - __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); - cx = 1 + w - cx - cw; - if (char_x_return) - *char_x_return = cx; - if (char_y_return) - *char_y_return = cy; - if (char_width_return) - *char_width_return = cw; - if (char_height_return) - *char_height_return = ch; - return; - break; + __imlib_calc_size(fn, &w, &h, text); + __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); + cx = 1 + w - cx - cw; + if (char_x_return) + *char_x_return = cx; + if (char_y_return) + *char_y_return = cy; + if (char_width_return) + *char_width_return = cw; + if (char_height_return) + *char_height_return = ch; + return; + break; case IMLIB_TEXT_TO_DOWN: - __imlib_calc_size(fn, &w, &h, text); - __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); - if (char_x_return) - *char_x_return = cy; - if (char_y_return) - *char_y_return = cx; - if (char_width_return) - *char_width_return = ch; - if (char_height_return) - *char_height_return = cw; - return; - break; + __imlib_calc_size(fn, &w, &h, text); + __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); + if (char_x_return) + *char_x_return = cy; + if (char_y_return) + *char_y_return = cx; + if (char_width_return) + *char_width_return = ch; + if (char_height_return) + *char_height_return = cw; + return; + break; case IMLIB_TEXT_TO_UP: - __imlib_calc_size(fn, &w, &h, text); - __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); - cy = 1 + h - cy - ch; - if (char_x_return) - *char_x_return = cy; - if (char_y_return) - *char_y_return = cx; - if (char_width_return) - *char_width_return = ch; - if (char_height_return) - *char_height_return = cw; - return; - break; + __imlib_calc_size(fn, &w, &h, text); + __imlib_char_geom(fn, text, index, &cx, &cy, &cw, &ch); + cy = 1 + h - cy - ch; + if (char_x_return) + *char_x_return = cy; + if (char_y_return) + *char_y_return = cx; + if (char_width_return) + *char_width_return = ch; + if (char_height_return) + *char_height_return = cw; + return; + break; default: - return; - break; - } + return; + break; + } } -char ** +char ** imlib_list_fonts(int *number_return) { - CHECK_PARAM_POINTER_RETURN("imlib_list_fonts", "number_return", number_return, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_list_fonts", "number_return", + number_return, NULL); return __imlib_list_fonts(number_return); } -void +void imlib_free_font_list(char **font_list, int number) { CHECK_PARAM_POINTER("imlib_free_font_list", "font_list", font_list); @@ -1809,19 +1839,19 @@ imlib_free_font_list(char **font_list, int number) __imlib_free_font_list(font_list, number); } -int +int imlib_get_font_cache_size(void) { return __imlib_get_font_cache_size(); } -void +void imlib_set_font_cache_size(int bytes) { __imlib_set_font_cache_size(bytes); } -void +void imlib_flush_font_cache(void) { __imlib_purge_font_cache(); @@ -1830,106 +1860,110 @@ imlib_flush_font_cache(void) int imlib_get_font_ascent(void) { - CHECK_PARAM_POINTER_RETURN("imlib_get_font_ascent", "font", ctxt_font , 0); - return ((ImlibFont *)ctxt_font)->ascent; + CHECK_PARAM_POINTER_RETURN("imlib_get_font_ascent", "font", ctxt_font, 0); + return ((ImlibFont *) ctxt_font)->ascent; } int imlib_get_font_descent(void) { - CHECK_PARAM_POINTER_RETURN("imlib_get_font_descent", "font", ctxt_font , 0); - return ((ImlibFont *)ctxt_font)->descent; + CHECK_PARAM_POINTER_RETURN("imlib_get_font_descent", "font", ctxt_font, 0); + return ((ImlibFont *) ctxt_font)->descent; } int imlib_get_maximum_font_ascent(void) { - CHECK_PARAM_POINTER_RETURN("imlib_get_maximum_font_ascent", "font", ctxt_font , 0); - return ((ImlibFont *)ctxt_font)->max_ascent; + CHECK_PARAM_POINTER_RETURN("imlib_get_maximum_font_ascent", "font", + ctxt_font, 0); + return ((ImlibFont *) ctxt_font)->max_ascent; } int imlib_get_maximum_font_descent(void) { - CHECK_PARAM_POINTER_RETURN("imlib_get_maximum_font_descent", "font", ctxt_font , 0); - return ((ImlibFont *)ctxt_font)->max_ascent; + CHECK_PARAM_POINTER_RETURN("imlib_get_maximum_font_descent", "font", + ctxt_font, 0); + return ((ImlibFont *) ctxt_font)->max_ascent; } - -Imlib_Color_Modifier -imlib_create_color_modifier(void) +Imlib_Color_Modifier imlib_create_color_modifier(void) { - return (Imlib_Color_Modifier)__imlib_CreateCmod(); + return (Imlib_Color_Modifier) __imlib_CreateCmod(); } -void +void imlib_free_color_modifier(void) { - CHECK_PARAM_POINTER("imlib_free_color_modifier", "color_modifier", ctxt_color_modifier); - __imlib_FreeCmod((ImlibColorModifier *)ctxt_color_modifier); + CHECK_PARAM_POINTER("imlib_free_color_modifier", "color_modifier", + ctxt_color_modifier); + __imlib_FreeCmod((ImlibColorModifier *) ctxt_color_modifier); ctxt_color_modifier = NULL; } -void +void imlib_modify_color_modifier_gamma(double gamma_value) { - CHECK_PARAM_POINTER("imlib_modify_color_modifier_gamma", "color_modifier", ctxt_color_modifier); - __imlib_CmodModGamma((ImlibColorModifier *)ctxt_color_modifier, - gamma_value); + CHECK_PARAM_POINTER("imlib_modify_color_modifier_gamma", "color_modifier", + ctxt_color_modifier); + __imlib_CmodModGamma((ImlibColorModifier *) ctxt_color_modifier, + gamma_value); } -void +void imlib_modify_color_modifier_brightness(double brightness_value) { - CHECK_PARAM_POINTER("imlib_modify_color_modifier_brightness", "color_modifier", ctxt_color_modifier); - __imlib_CmodModBrightness((ImlibColorModifier *)ctxt_color_modifier, - brightness_value); + CHECK_PARAM_POINTER("imlib_modify_color_modifier_brightness", + "color_modifier", ctxt_color_modifier); + __imlib_CmodModBrightness((ImlibColorModifier *) ctxt_color_modifier, + brightness_value); } -void +void imlib_modify_color_modifier_contrast(double contrast_value) { - CHECK_PARAM_POINTER("imlib_modify_color_modifier_contrast", "color_modifier", ctxt_color_modifier); - __imlib_CmodModContrast((ImlibColorModifier *)ctxt_color_modifier, - contrast_value); + CHECK_PARAM_POINTER("imlib_modify_color_modifier_contrast", "color_modifier", + ctxt_color_modifier); + __imlib_CmodModContrast((ImlibColorModifier *) ctxt_color_modifier, + contrast_value); } -void -imlib_set_color_modifier_tables(DATA8 *red_table, - DATA8 *green_table, - DATA8 *blue_table, - DATA8 *alpha_table) +void +imlib_set_color_modifier_tables(DATA8 * red_table, DATA8 * green_table, + DATA8 * blue_table, DATA8 * alpha_table) { - CHECK_PARAM_POINTER("imlib_set_color_modifier_tables", "color_modifier", ctxt_color_modifier); - __imlib_CmodSetTables((ImlibColorModifier *)ctxt_color_modifier, - red_table, green_table, blue_table, alpha_table); + CHECK_PARAM_POINTER("imlib_set_color_modifier_tables", "color_modifier", + ctxt_color_modifier); + __imlib_CmodSetTables((ImlibColorModifier *) ctxt_color_modifier, red_table, + green_table, blue_table, alpha_table); } -void -imlib_get_color_modifier_tables(DATA8 *red_table, - DATA8 *green_table, - DATA8 *blue_table, - DATA8 *alpha_table) +void +imlib_get_color_modifier_tables(DATA8 * red_table, DATA8 * green_table, + DATA8 * blue_table, DATA8 * alpha_table) { - CHECK_PARAM_POINTER("imlib_get_color_modifier_tables", "color_modifier", ctxt_color_modifier); - __imlib_CmodGetTables((ImlibColorModifier *)ctxt_color_modifier, - red_table, green_table, blue_table, alpha_table); + CHECK_PARAM_POINTER("imlib_get_color_modifier_tables", "color_modifier", + ctxt_color_modifier); + __imlib_CmodGetTables((ImlibColorModifier *) ctxt_color_modifier, red_table, + green_table, blue_table, alpha_table); } void imlib_reset_color_modifier(void) { - CHECK_PARAM_POINTER("imlib_rset_color_modifier", "color_modifier", ctxt_color_modifier); - __imlib_CmodReset((ImlibColorModifier *)ctxt_color_modifier); + CHECK_PARAM_POINTER("imlib_rset_color_modifier", "color_modifier", + ctxt_color_modifier); + __imlib_CmodReset((ImlibColorModifier *) ctxt_color_modifier); } -void +void imlib_apply_color_modifier(void) { - ImlibImage *im; - + ImlibImage *im; + CHECK_PARAM_POINTER("imlib_apply_color_modifier", "image", ctxt_image); - CHECK_PARAM_POINTER("imlib_apply_color_modifier", "color_modifier", ctxt_color_modifier); + CHECK_PARAM_POINTER("imlib_apply_color_modifier", "color_modifier", + ctxt_color_modifier); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -1938,22 +1972,24 @@ imlib_apply_color_modifier(void) __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); __imlib_DataCmodApply(im->data, im->w, im->h, 0, &im->flags, - (ImlibColorModifier *)ctxt_color_modifier); + (ImlibColorModifier *) ctxt_color_modifier); } -void +void imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height) { - ImlibImage *im; - - CHECK_PARAM_POINTER("imlib_apply_color_modifier_to_rectangle", "image", ctxt_image); - CHECK_PARAM_POINTER("imlib_apply_color_modifier_to_rectangle", "color_modifier", ctxt_color_modifier); + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_apply_color_modifier_to_rectangle", "image", + ctxt_image); + CHECK_PARAM_POINTER("imlib_apply_color_modifier_to_rectangle", + "color_modifier", ctxt_color_modifier); CAST_IMAGE(im, ctxt_image); if (x < 0) - { - width += x; - x = 0; - } + { + width += x; + x = 0; + } if (width <= 0) return; if ((x + width) > im->w) @@ -1961,10 +1997,10 @@ imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height) if (width <= 0) return; if (y < 0) - { - height += y; - y = 0; - } + { + height += y; + y = 0; + } if (height <= 0) return; if ((y + height) > im->h) @@ -1977,17 +2013,18 @@ imlib_apply_color_modifier_to_rectangle(int x, int y, int width, int height) return; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - __imlib_DataCmodApply(im->data + (y * im->w) + x, width, height, - im->w - width, &im->flags, - (ImlibColorModifier *)ctxt_color_modifier); + __imlib_DataCmodApply(im->data + (y * im->w) + x, width, height, + im->w - width, &im->flags, + (ImlibColorModifier *) ctxt_color_modifier); } -Imlib_Updates -imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates) +Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2, + char make_updates) { - ImlibImage *im; - - CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line", "image", ctxt_image, NULL); + ImlibImage *im; + + CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line", "image", ctxt_image, + NULL); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -1995,21 +2032,23 @@ imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_updates) return NULL; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - return (Imlib_Updates)__imlib_draw_line(im, x1, y1, x2, y2, - (DATA8)ctxt_color.red, - (DATA8)ctxt_color.green, - (DATA8)ctxt_color.blue, - (DATA8)ctxt_color.alpha, - ctxt_operation, - (char)make_updates); + return (Imlib_Updates) __imlib_draw_line(im, x1, y1, x2, y2, + (DATA8) ctxt_color.red, + (DATA8) ctxt_color.green, + (DATA8) ctxt_color.blue, + (DATA8) ctxt_color.alpha, + ctxt_operation, (char)make_updates); } -Imlib_Updates -imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax, char make_updates) -{ - ImlibImage *im; - - CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line_clipped", "image", ctxt_image, NULL); +Imlib_Updates imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, + int clip_xmin, int clip_xmax, + int clip_ymin, int clip_ymax, + char make_updates) +{ + ImlibImage *im; + + CHECK_PARAM_POINTER_RETURN("imlib_image_draw_line_clipped", "image", + ctxt_image, NULL); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -2017,22 +2056,22 @@ imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, int clip_xmin, int return NULL; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - return (Imlib_Updates)__imlib_draw_line_clipped(im, x1, y1, x2, y2, - clip_xmin, clip_xmax, clip_ymin, clip_ymax, - (DATA8)ctxt_color.red, - (DATA8)ctxt_color.green, - (DATA8)ctxt_color.blue, - (DATA8)ctxt_color.alpha, - ctxt_operation, - (char)make_updates); + return (Imlib_Updates) __imlib_draw_line_clipped(im, x1, y1, x2, y2, + clip_xmin, clip_xmax, + clip_ymin, clip_ymax, + (DATA8) ctxt_color.red, + (DATA8) ctxt_color.green, + (DATA8) ctxt_color.blue, + (DATA8) ctxt_color.alpha, + ctxt_operation, + (char)make_updates); } - -void +void imlib_image_draw_rectangle(int x, int y, int width, int height) { - ImlibImage *im; - + ImlibImage *im; + CHECK_PARAM_POINTER("imlib_image_draw_rectangle", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -2042,14 +2081,35 @@ imlib_image_draw_rectangle(int x, int y, int width, int height) __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); __imlib_draw_box(im, x, y, width, height, ctxt_color.red, ctxt_color.green, - ctxt_color.blue, ctxt_color.alpha, ctxt_operation); + ctxt_color.blue, ctxt_color.alpha, ctxt_operation); } -void +void +imlib_image_draw_rectangle_clipped(int x, int y, int width, int height, + int clip_xmin, int clip_xmax, int clip_ymin, + int clip_ymax) +{ + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_image_draw_rectangle", "image", ctxt_image); + CAST_IMAGE(im, ctxt_image); + if ((!(im->data)) && (im->loader) && (im->loader->load)) + im->loader->load(im, NULL, 0, 1); + if (!(im->data)) + return; + __imlib_DirtyImage(im); + __imlib_DirtyPixmapsForImage(im); + __imlib_draw_box_clipped(im, x, y, width, height, clip_xmin, clip_xmax, + clip_ymin, clip_ymax, ctxt_color.red, + ctxt_color.green, ctxt_color.blue, ctxt_color.alpha, + ctxt_operation); +} + +void imlib_image_fill_rectangle(int x, int y, int width, int height) { - ImlibImage *im; - + ImlibImage *im; + CHECK_PARAM_POINTER("imlib_image_fill_rectangle", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -2058,19 +2118,20 @@ imlib_image_fill_rectangle(int x, int y, int width, int height) return; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - __imlib_draw_filled_box(im, x, y, width, height, ctxt_color.red, - ctxt_color.green, ctxt_color.blue, - ctxt_color.alpha, ctxt_operation); + __imlib_draw_filled_box(im, x, y, width, height, ctxt_color.red, + ctxt_color.green, ctxt_color.blue, ctxt_color.alpha, + ctxt_operation); } -void -imlib_image_copy_alpha_to_image(Imlib_Image image_source, - int x, int y) +void +imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y) { - ImlibImage *im, *im2; - - CHECK_PARAM_POINTER("imlib_image_copy_alpha_to_image", "image_source", image_source); - CHECK_PARAM_POINTER("imlib_image_copy_alpha_to_image", "image_destination", ctxt_image); + ImlibImage *im, *im2; + + CHECK_PARAM_POINTER("imlib_image_copy_alpha_to_image", "image_source", + image_source); + CHECK_PARAM_POINTER("imlib_image_copy_alpha_to_image", "image_destination", + ctxt_image); CAST_IMAGE(im, image_source); CAST_IMAGE(im2, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -2086,16 +2147,17 @@ imlib_image_copy_alpha_to_image(Imlib_Image image_source, __imlib_copy_alpha_data(im, im2, 0, 0, im->w, im->h, x, y); } -void -imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source, - int x, int y, int width, - int height, int destination_x, - int destination_y) +void +imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source, int x, + int y, int width, int height, + int destination_x, int destination_y) { - ImlibImage *im, *im2; - - CHECK_PARAM_POINTER("imlib_image_copy_alpha_rectangle_to_image", "image_source", image_source); - CHECK_PARAM_POINTER("imlib_image_copy_alpha_rectangle_to_image", "image_destination", ctxt_image); + ImlibImage *im, *im2; + + CHECK_PARAM_POINTER("imlib_image_copy_alpha_rectangle_to_image", + "image_source", image_source); + CHECK_PARAM_POINTER("imlib_image_copy_alpha_rectangle_to_image", + "image_destination", ctxt_image); CAST_IMAGE(im, image_source); CAST_IMAGE(im2, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -2108,17 +2170,17 @@ imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source, return; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - __imlib_copy_alpha_data(im, im2, x, y, width, height, destination_x, - destination_y); + __imlib_copy_alpha_data(im, im2, x, y, width, height, destination_x, + destination_y); } -void -imlib_image_scroll_rect(int x, int y, int width, int height, int delta_x, - int delta_y) +void +imlib_image_scroll_rect(int x, int y, int width, int height, int delta_x, + int delta_y) { - ImlibImage *im; - int xx, yy, w, h, nx, ny; - + ImlibImage *im; + int xx, yy, w, h, nx, ny; + CHECK_PARAM_POINTER("imlib_image_scroll_rect", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -2126,39 +2188,39 @@ imlib_image_scroll_rect(int x, int y, int width, int height, int delta_x, if (!(im->data)) return; if (delta_x > 0) - { - xx = x; - nx = x + delta_x; - w = width - delta_x; - } + { + xx = x; + nx = x + delta_x; + w = width - delta_x; + } else - { - xx = x - delta_x; - nx = x; - w = width + delta_x; - } + { + xx = x - delta_x; + nx = x; + w = width + delta_x; + } if (delta_y > 0) - { - yy = y; - ny = y + delta_y; - h = height - delta_y; - } + { + yy = y; + ny = y + delta_y; + h = height - delta_y; + } else - { - yy = y - delta_y; - ny = y; - h = height + delta_y; - } + { + yy = y - delta_y; + ny = y; + h = height + delta_y; + } __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); __imlib_copy_image_data(im, xx, yy, w, h, nx, ny); } -void -imlib_image_copy_rect(int x, int y, int width, int height, int new_x,int new_y) +void +imlib_image_copy_rect(int x, int y, int width, int height, int new_x, int new_y) { - ImlibImage *im; - + ImlibImage *im; + CHECK_PARAM_POINTER("imlib_image_copy_rect", "image", ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) @@ -2170,37 +2232,40 @@ imlib_image_copy_rect(int x, int y, int width, int height, int new_x,int new_y) __imlib_copy_image_data(im, x, y, width, height, new_x, new_y); } -Imlib_Color_Range -imlib_create_color_range(void) +Imlib_Color_Range imlib_create_color_range(void) { - return (Imlib_Color_Range)__imlib_CreateRange(); + return (Imlib_Color_Range) __imlib_CreateRange(); } -void +void imlib_free_color_range(void) { - CHECK_PARAM_POINTER("imlib_free_color_range", "color_range", ctxt_color_range); - __imlib_FreeRange((ImlibRange *)ctxt_color_range); + CHECK_PARAM_POINTER("imlib_free_color_range", "color_range", + ctxt_color_range); + __imlib_FreeRange((ImlibRange *) ctxt_color_range); ctxt_color_range = NULL; } -void +void imlib_add_color_to_color_range(int distance_away) { - CHECK_PARAM_POINTER("imlib_add_color_to_color_range", "color_range", ctxt_color_range); - __imlib_AddRangeColor((ImlibRange *)ctxt_color_range, - ctxt_color.red, ctxt_color.green, ctxt_color.blue, - ctxt_color.alpha, distance_away); + CHECK_PARAM_POINTER("imlib_add_color_to_color_range", "color_range", + ctxt_color_range); + __imlib_AddRangeColor((ImlibRange *) ctxt_color_range, ctxt_color.red, + ctxt_color.green, ctxt_color.blue, ctxt_color.alpha, + distance_away); } -void +void imlib_image_fill_color_range_rectangle(int x, int y, int width, int height, - double angle) + double angle) { - ImlibImage *im; - - CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle", "image", ctxt_image); - CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle", "color_range", ctxt_color_range); + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle", "image", + ctxt_image); + CHECK_PARAM_POINTER("imlib_image_fill_color_range_rectangle", "color_range", + ctxt_color_range); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -2208,16 +2273,16 @@ imlib_image_fill_color_range_rectangle(int x, int y, int width, int height, return; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - __imlib_DrawGradient(im, x, y, width, height, - (ImlibRange *)ctxt_color_range, angle, ctxt_operation); + __imlib_DrawGradient(im, x, y, width, height, + (ImlibRange *) ctxt_color_range, angle, ctxt_operation); } void -imlib_image_query_pixel(int x, int y, Imlib_Color *color_return) +imlib_image_query_pixel(int x, int y, Imlib_Color * color_return) { - ImlibImage *im; - DATA32 *p; - + ImlibImage *im; + DATA32 *p; + CHECK_PARAM_POINTER("imlib_image_query_pixel", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_image_query_pixel", "color_return", color_return); CAST_IMAGE(im, ctxt_image); @@ -2226,13 +2291,13 @@ imlib_image_query_pixel(int x, int y, Imlib_Color *color_return) if (!(im->data)) return; if ((x < 0) || (x >= im->w) || (y < 0) || (y >= im->h)) - { - color_return->red = 0; - color_return->green = 0; - color_return->blue = 0; - color_return->alpha = 0; - return; - } + { + color_return->red = 0; + color_return->green = 0; + color_return->blue = 0; + color_return->alpha = 0; + return; + } p = im->data + (im->w * y) + x; color_return->red = ((*p) >> 16) & 0xff; color_return->green = ((*p) >> 8) & 0xff; @@ -2240,27 +2305,30 @@ imlib_image_query_pixel(int x, int y, Imlib_Color *color_return) color_return->alpha = ((*p) >> 24) & 0xff; } -void +void imlib_image_attach_data_value(const char *key, void *data, int value, - Imlib_Internal_Data_Destructor_Function destructor_function) + Imlib_Internal_Data_Destructor_Function + destructor_function) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_attach_data_value", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_image_attach_data_value", "key", key); CAST_IMAGE(im, ctxt_image); __imlib_AttachTag(im, key, value, data, - (ImlibDataDestructorFunction)destructor_function); + (ImlibDataDestructorFunction) destructor_function); } -void * +void * imlib_image_get_attached_data(const char *key) { - ImlibImageTag *t; - ImlibImage *im; - - CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_data", "image", ctxt_image, NULL); - CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_data", "key", key, NULL); + ImlibImageTag *t; + ImlibImage *im; + + CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_data", "image", + ctxt_image, NULL); + CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_data", "key", key, + NULL); CAST_IMAGE(im, ctxt_image); t = __imlib_GetTag(im, key); if (t) @@ -2271,10 +2339,11 @@ imlib_image_get_attached_data(const char *key) int imlib_image_get_attached_value(const char *key) { - ImlibImageTag *t; - ImlibImage *im; - - CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_value", "image", ctxt_image, 0); + ImlibImageTag *t; + ImlibImage *im; + + CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_value", "image", + ctxt_image, 0); CHECK_PARAM_POINTER_RETURN("imlib_image_get_attached_value", "key", key, 0); CAST_IMAGE(im, ctxt_image); t = __imlib_GetTag(im, key); @@ -2283,25 +2352,28 @@ imlib_image_get_attached_value(const char *key) return 0; } -void +void imlib_image_remove_attached_data_value(const char *key) { - ImlibImage *im; - - CHECK_PARAM_POINTER("imlib_image_remove_attached_data_value", "image", ctxt_image); + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_image_remove_attached_data_value", "image", + ctxt_image); CHECK_PARAM_POINTER("imlib_image_remove_attached_data_value", "key", key); CAST_IMAGE(im, ctxt_image); __imlib_RemoveTag(im, key); } -void +void imlib_image_remove_and_free_attached_data_value(const char *key) { - ImlibImageTag *t; - ImlibImage *im; - - CHECK_PARAM_POINTER("imlib_image_remove_and_free_attached_data_value", "image", ctxt_image); - CHECK_PARAM_POINTER("imlib_image_remove_and_free_attached_data_value", "key", key); + ImlibImageTag *t; + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_image_remove_and_free_attached_data_value", + "image", ctxt_image); + CHECK_PARAM_POINTER("imlib_image_remove_and_free_attached_data_value", "key", + key); CAST_IMAGE(im, ctxt_image); t = __imlib_RemoveTag(im, key); __imlib_FreeTag(im, t); @@ -2310,9 +2382,9 @@ imlib_image_remove_and_free_attached_data_value(const char *key) void imlib_save_image(const char *filename) { - ImlibImage *im; - Imlib_Image prev_ctxt_image; - + ImlibImage *im; + Imlib_Image prev_ctxt_image; + CHECK_PARAM_POINTER("imlib_save_image", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_save_image", "filename", filename); CAST_IMAGE(im, ctxt_image); @@ -2321,149 +2393,152 @@ imlib_save_image(const char *filename) if (!im->data) return; prev_ctxt_image = ctxt_image; - __imlib_SaveImage(im, filename, (ImlibProgressFunction)ctxt_progress_func, - ctxt_progress_granularity, NULL); + __imlib_SaveImage(im, filename, (ImlibProgressFunction) ctxt_progress_func, + ctxt_progress_granularity, NULL); ctxt_image = prev_ctxt_image; } void imlib_save_image_with_error_return(const char *filename, - Imlib_Load_Error *error_return) + Imlib_Load_Error * error_return) { - ImlibImage *im; - Imlib_Image prev_ctxt_image; - - CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "image", ctxt_image); - CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "filename", filename); - CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "error_return", error_return); + ImlibImage *im; + Imlib_Image prev_ctxt_image; + + CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "image", + ctxt_image); + CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "filename", + filename); + CHECK_PARAM_POINTER("imlib_save_image_with_error_return", "error_return", + error_return); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); if (!im->data) return; prev_ctxt_image = ctxt_image; - __imlib_SaveImage(im, filename, (ImlibProgressFunction)ctxt_progress_func, - ctxt_progress_granularity, error_return); + __imlib_SaveImage(im, filename, (ImlibProgressFunction) ctxt_progress_func, + ctxt_progress_granularity, error_return); ctxt_image = prev_ctxt_image; } -Imlib_Image -imlib_create_rotated_image(double angle) +Imlib_Image imlib_create_rotated_image(double angle) { - ImlibImage *im, *im_old; - DATA32 *data; - int x, y, dx, dy, sz; - double x1, y1, d; - - CHECK_PARAM_POINTER_RETURN("imlib_create_rotated_image", "image", - ctxt_image, NULL); + ImlibImage *im, *im_old; + DATA32 *data; + int x, y, dx, dy, sz; + double x1, y1, d; + + CHECK_PARAM_POINTER_RETURN("imlib_create_rotated_image", "image", ctxt_image, + NULL); CAST_IMAGE(im_old, ctxt_image); if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load)) im_old->loader->load(im_old, NULL, 0, 1); if (!(im_old->data)) return NULL; - + d = hypot((double)(im_old->w + 4), (double)(im_old->h + 4)) / sqrt(2.0); - + x1 = (double)(im_old->w) / 2.0 - sin(angle + atan(1.0)) * d; y1 = (double)(im_old->h) / 2.0 - cos(angle + atan(1.0)) * d; - + sz = (int)(d * sqrt(2.0)); x = (int)(x1 * _ROTATE_PREC_MAX); y = (int)(y1 * _ROTATE_PREC_MAX); dx = (int)(cos(angle) * _ROTATE_PREC_MAX); dy = -(int)(sin(angle) * _ROTATE_PREC_MAX); - + im = __imlib_CreateImage(sz, sz, NULL); im->data = calloc(sz * sz, sizeof(DATA32)); - if (!(im->data)) - { - __imlib_FreeImage(im); - return NULL; - } - - if (ctxt_anti_alias) - { + if (!(im->data)) + { + __imlib_FreeImage(im); + return NULL; + } + + if (ctxt_anti_alias) + { #ifdef DO_MMX_ASM - if (__imlib_get_cpuid() & CPUID_MMX) - __imlib_mmx_RotateAA(im_old->data, im->data, im_old->w, - im_old->w, im_old->h, im->w, sz, sz, x, y, - dx, dy, -dy, dx); - else + if (__imlib_get_cpuid() & CPUID_MMX) + __imlib_mmx_RotateAA(im_old->data, im->data, im_old->w, im_old->w, + im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx); + else #endif - __imlib_RotateAA(im_old->data, im->data, im_old->w, - im_old->w, im_old->h, im->w, sz, sz, x, y, - dx, dy, -dy, dx); - } else - { - __imlib_RotateSample(im_old->data, im->data, im_old->w, - im_old->w, im_old->h, im->w, sz, sz, x, y, - dx, dy, -dy, dx); - } + __imlib_RotateAA(im_old->data, im->data, im_old->w, im_old->w, + im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx); + } + else + { + __imlib_RotateSample(im_old->data, im->data, im_old->w, im_old->w, + im_old->h, im->w, sz, sz, x, y, dx, dy, -dy, dx); + } SET_FLAG(im->flags, F_HAS_ALPHA); - - return (Imlib_Image)im; + + return (Imlib_Image) im; } -void +void imlib_blend_image_onto_image_at_angle(Imlib_Image source_image, - char merge_alpha, - int source_x, int source_y, - int source_width, int source_height, - int destination_x, int destination_y, - int angle_x, int angle_y) + char merge_alpha, int source_x, + int source_y, int source_width, + int source_height, int destination_x, + int destination_y, int angle_x, + int angle_y) { - ImlibImage *im_src, *im_dst; - - CHECK_PARAM_POINTER("imlib_blend_image_onto_image_at_angle", "source_image", source_image); - CHECK_PARAM_POINTER("imlib_blend_image_onto_image_at_angle", "image", ctxt_image); + ImlibImage *im_src, *im_dst; + + CHECK_PARAM_POINTER("imlib_blend_image_onto_image_at_angle", "source_image", + source_image); + CHECK_PARAM_POINTER("imlib_blend_image_onto_image_at_angle", "image", + ctxt_image); CAST_IMAGE(im_src, source_image); CAST_IMAGE(im_dst, ctxt_image); __imlib_DirtyImage(im_dst); __imlib_DirtyPixmapsForImage(im_dst); - __imlib_BlendImageToImageSkewed(im_src, im_dst, ctxt_anti_alias, - ctxt_blend, merge_alpha, source_x, source_y, - source_width, source_height, - destination_x, destination_y, - angle_x, angle_y, 0, 0, - ctxt_color_modifier, ctxt_operation); + __imlib_BlendImageToImageSkewed(im_src, im_dst, ctxt_anti_alias, ctxt_blend, + merge_alpha, source_x, source_y, + source_width, source_height, destination_x, + destination_y, angle_x, angle_y, 0, 0, + ctxt_color_modifier, ctxt_operation); } -void -imlib_blend_image_onto_image_skewed(Imlib_Image source_image, - char merge_alpha, - int source_x, int source_y, - int source_width, int source_height, - int destination_x, int destination_y, - int h_angle_x, int h_angle_y, - int v_angle_x, int v_angle_y) +void +imlib_blend_image_onto_image_skewed(Imlib_Image source_image, char merge_alpha, + int source_x, int source_y, + int source_width, int source_height, + int destination_x, int destination_y, + int h_angle_x, int h_angle_y, int v_angle_x, + int v_angle_y) { - ImlibImage *im_src, *im_dst; - - CHECK_PARAM_POINTER("imlib_blend_image_onto_image_skewed", "source_image", source_image); - CHECK_PARAM_POINTER("imlib_blend_image_onto_image_skewed", "image", ctxt_image); + ImlibImage *im_src, *im_dst; + + CHECK_PARAM_POINTER("imlib_blend_image_onto_image_skewed", "source_image", + source_image); + CHECK_PARAM_POINTER("imlib_blend_image_onto_image_skewed", "image", + ctxt_image); CAST_IMAGE(im_src, source_image); CAST_IMAGE(im_dst, ctxt_image); __imlib_DirtyImage(im_dst); __imlib_DirtyPixmapsForImage(im_dst); - __imlib_BlendImageToImageSkewed(im_src, im_dst, ctxt_anti_alias, - ctxt_blend, merge_alpha, source_x, source_y, - source_width, source_height, - destination_x, destination_y, - h_angle_x, h_angle_y, v_angle_x, v_angle_y, - ctxt_color_modifier, ctxt_operation); + __imlib_BlendImageToImageSkewed(im_src, im_dst, ctxt_anti_alias, ctxt_blend, + merge_alpha, source_x, source_y, + source_width, source_height, destination_x, + destination_y, h_angle_x, h_angle_y, + v_angle_x, v_angle_y, ctxt_color_modifier, + ctxt_operation); } -void +void imlib_render_image_on_drawable_skewed(int source_x, int source_y, - int source_width, int source_height, - int destination_x, int destination_y, - int h_angle_x, int h_angle_y, - int v_angle_x, int v_angle_y) + int source_width, int source_height, + int destination_x, int destination_y, + int h_angle_x, int h_angle_y, + int v_angle_x, int v_angle_y) { - ImlibImage *im; - - CHECK_PARAM_POINTER("imlib_render_image_on_drawable_skewed", "image", ctxt_image); + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_render_image_on_drawable_skewed", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -2471,24 +2546,24 @@ imlib_render_image_on_drawable_skewed(int source_x, int source_y, return; CAST_IMAGE(im, ctxt_image); __imlib_RenderImageSkewed(ctxt_display, im, ctxt_drawable, ctxt_mask, - ctxt_visual, ctxt_colormap, ctxt_depth, - source_x, source_y, source_width, source_height, - destination_x, destination_y, - h_angle_x, h_angle_y, v_angle_x, v_angle_y, - ctxt_anti_alias, ctxt_dither, ctxt_blend, - ctxt_dither_mask, ctxt_color_modifier, - ctxt_operation); + ctxt_visual, ctxt_colormap, ctxt_depth, source_x, + source_y, source_width, source_height, + destination_x, destination_y, h_angle_x, h_angle_y, + v_angle_x, v_angle_y, ctxt_anti_alias, ctxt_dither, + ctxt_blend, ctxt_dither_mask, ctxt_color_modifier, + ctxt_operation); } -void +void imlib_render_image_on_drawable_at_angle(int source_x, int source_y, - int source_width, int source_height, - int destination_x, int destination_y, - int angle_x, int angle_y) + int source_width, int source_height, + int destination_x, int destination_y, + int angle_x, int angle_y) { - ImlibImage *im; - - CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_angle", "image", ctxt_image); + ImlibImage *im; + + CHECK_PARAM_POINTER("imlib_render_image_on_drawable_at_angle", "image", + ctxt_image); CAST_IMAGE(im, ctxt_image); if ((!(im->data)) && (im->loader) && (im->loader->load)) im->loader->load(im, NULL, 0, 1); @@ -2496,19 +2571,18 @@ imlib_render_image_on_drawable_at_angle(int source_x, int source_y, return; CAST_IMAGE(im, ctxt_image); __imlib_RenderImageSkewed(ctxt_display, im, ctxt_drawable, ctxt_mask, - ctxt_visual, ctxt_colormap, ctxt_depth, - source_x, source_y, source_width, source_height, - destination_x, destination_y, - angle_x, angle_y, 0, 0, - ctxt_anti_alias, ctxt_dither, ctxt_blend, - ctxt_dither_mask, ctxt_color_modifier, - ctxt_operation); + ctxt_visual, ctxt_colormap, ctxt_depth, source_x, + source_y, source_width, source_height, + destination_x, destination_y, angle_x, angle_y, 0, + 0, ctxt_anti_alias, ctxt_dither, ctxt_blend, + ctxt_dither_mask, ctxt_color_modifier, + ctxt_operation); } void imlib_image_filter(void) { - ImlibImage *im; + ImlibImage *im; CHECK_PARAM_POINTER("imlib_image_filter", "image", ctxt_image); CHECK_PARAM_POINTER("imlib_image_filter", "filter", ctxt_filter); @@ -2519,20 +2593,19 @@ imlib_image_filter(void) return; __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); - __imlib_FilterImage(im, (ImlibFilter *)ctxt_filter); + __imlib_FilterImage(im, (ImlibFilter *) ctxt_filter); } -Imlib_Filter -imlib_create_filter(int initsize) +Imlib_Filter imlib_create_filter(int initsize) { - return (Imlib_Filter)__imlib_CreateFilter(initsize); + return (Imlib_Filter) __imlib_CreateFilter(initsize); } void imlib_free_filter(void) { CHECK_PARAM_POINTER("imlib_free_filter", "filter", ctxt_filter); - __imlib_FreeFilter((ImlibFilter *)ctxt_filter); + __imlib_FreeFilter((ImlibFilter *) ctxt_filter); ctxt_filter = NULL; } @@ -2542,8 +2615,7 @@ imlib_context_set_filter(Imlib_Filter filter) ctxt_filter = filter; } -Imlib_Filter -imlib_context_get_filter(void) +Imlib_Filter imlib_context_get_filter(void) { return ctxt_filter; } @@ -2551,48 +2623,53 @@ imlib_context_get_filter(void) void imlib_filter_set(int xoff, int yoff, int a, int r, int g, int b) { - ImlibFilter *fil; + ImlibFilter *fil; + CHECK_PARAM_POINTER("imlib_filter_set", "filter", ctxt_filter); - fil = (ImlibFilter *)ctxt_filter; + fil = (ImlibFilter *) ctxt_filter; __imlib_FilterSetColor(&fil->alpha, xoff, yoff, a, 0, 0, 0); - __imlib_FilterSetColor(&fil->red, xoff, yoff, 0, r, 0, 0); + __imlib_FilterSetColor(&fil->red, xoff, yoff, 0, r, 0, 0); __imlib_FilterSetColor(&fil->green, xoff, yoff, 0, 0, g, 0); - __imlib_FilterSetColor(&fil->blue, xoff, yoff, 0, 0, 0, b); + __imlib_FilterSetColor(&fil->blue, xoff, yoff, 0, 0, 0, b); } void imlib_filter_set_alpha(int xoff, int yoff, int a, int r, int g, int b) { - ImlibFilter *fil; + ImlibFilter *fil; + CHECK_PARAM_POINTER("imlib_filter_set_alpha", "filter", ctxt_filter); - fil = (ImlibFilter *)ctxt_filter; + fil = (ImlibFilter *) ctxt_filter; __imlib_FilterSetColor(&fil->alpha, xoff, yoff, a, r, g, b); } void imlib_filter_set_red(int xoff, int yoff, int a, int r, int g, int b) { - ImlibFilter *fil; + ImlibFilter *fil; + CHECK_PARAM_POINTER("imlib_filter_set_red", "filter", ctxt_filter); - fil = (ImlibFilter *)ctxt_filter; + fil = (ImlibFilter *) ctxt_filter; __imlib_FilterSetColor(&fil->red, xoff, yoff, a, r, g, b); } void imlib_filter_set_green(int xoff, int yoff, int a, int r, int g, int b) { - ImlibFilter *fil; + ImlibFilter *fil; + CHECK_PARAM_POINTER("imlib_filter_set_green", "filter", ctxt_filter); - fil = (ImlibFilter *)ctxt_filter; + fil = (ImlibFilter *) ctxt_filter; __imlib_FilterSetColor(&fil->green, xoff, yoff, a, r, g, b); } void imlib_filter_set_blue(int xoff, int yoff, int a, int r, int g, int b) { - ImlibFilter *fil; + ImlibFilter *fil; + CHECK_PARAM_POINTER("imlib_filter_set_blue", "filter", ctxt_filter); - fil = (ImlibFilter *)ctxt_filter; + fil = (ImlibFilter *) ctxt_filter; __imlib_FilterSetColor(&fil->blue, xoff, yoff, a, r, g, b); } @@ -2600,23 +2677,24 @@ void imlib_filter_constants(int a, int r, int g, int b) { CHECK_PARAM_POINTER("imlib_filter_constants", "filter", ctxt_filter); - __imlib_FilterConstants((ImlibFilter *)ctxt_filter, a, r, g, b); + __imlib_FilterConstants((ImlibFilter *) ctxt_filter, a, r, g, b); } void imlib_filter_divisors(int a, int r, int g, int b) { CHECK_PARAM_POINTER("imlib_filter_divisors", "filter", ctxt_filter); - __imlib_FilterDivisors((ImlibFilter *)ctxt_filter, a, r, g, b); + __imlib_FilterDivisors((ImlibFilter *) ctxt_filter, a, r, g, b); } -void imlib_apply_filter(char *script, ...) +void +imlib_apply_filter(char *script, ...) { - va_list param_list; - Imlib_Image im; - + va_list param_list; + Imlib_Image im; + __imlib_dynamic_filters_init(); - CAST_IMAGE(im, ctxt_image); + CAST_IMAGE(im, ctxt_image); __imlib_DirtyImage(im); __imlib_DirtyPixmapsForImage(im); va_start(param_list, script); diff --git a/src/rgbadraw.c b/src/rgbadraw.c index e02984b..dd4d59a 100644 --- a/src/rgbadraw.c +++ b/src/rgbadraw.c @@ -1237,6 +1237,24 @@ __imlib_draw_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r, DATA8 g, __imlib_draw_line(im, x + w - 1, y, x + w - 1, y + h - 1, r, g, b, a, op, 0); } +void +__imlib_draw_box_clipped(ImlibImage * im, int x, int y, int w, int h, + int clip_xmin, int clip_xmax, int clip_ymin, + int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a, + ImlibOp op) +{ + __imlib_draw_line_clipped(im, x, y, x + w - 1, y, clip_xmin, clip_xmax, + clip_ymin, clip_ymax, r, g, b, a, op, 0); + __imlib_draw_line_clipped(im, x, y, x, y + h - 1, clip_xmin, clip_xmax, + clip_ymin, clip_ymax, r, g, b, a, op, 0); + __imlib_draw_line_clipped(im, x, y + h - 1, x + w - 1, y + h - 1, clip_xmin, + clip_xmax, clip_ymin, clip_ymax, r, g, b, a, op, + 0); + __imlib_draw_line_clipped(im, x + w - 1, y, x + w - 1, y + h - 1, clip_xmin, + clip_xmax, clip_ymin, clip_ymax, r, g, b, a, op, + 0); +} + void __imlib_draw_filled_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op) @@ -1592,8 +1610,9 @@ __imlib_clip_line(int x0, int y0, int x1, int y1, int xmin, int xmax, int ymin, return accept; } -ImlibOutCode __imlib_comp_outcode(double x, double y, double xmin, double xmax, - double ymin, double ymax) +ImlibOutCode +__imlib_comp_outcode(double x, double y, double xmin, double xmax, double ymin, + double ymax) { ImlibOutCode code = 0; diff --git a/src/rgbadraw.h b/src/rgbadraw.h index 838d0f5..db1418f 100644 --- a/src/rgbadraw.h +++ b/src/rgbadraw.h @@ -33,4 +33,9 @@ __imlib_draw_line_clipped(ImlibImage * im, int x1, int y1, int x2, int y2, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a, ImlibOp op, char make_updates); +void +__imlib_draw_box_clipped(ImlibImage * im, int x, int y, int w, int h, + int clip_xmin, int clip_xmax, int clip_ymin, + int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a, + ImlibOp op); #endif diff --git a/test/main.c b/test/main.c index 8b46ddb..62addcb 100644 --- a/test/main.c +++ b/test/main.c @@ -760,9 +760,59 @@ int main (int argc, char **argv) imlib_context_set_color(255, 255, 255, 255); uu = imlib_image_draw_line(200, 200, x, y, 1); + up = imlib_updates_append_updates(up, uu); + + /* test line clipping */ + imlib_image_draw_rectangle(50,50,100,100); + up = imlib_update_append_rect(up, 50,50,100,100); + + imlib_context_set_color(255, 255, 255, 255); + uu = imlib_image_draw_line(0, 0, 200, 200, 1); up = imlib_updates_append_updates(up, uu); - uu = imlib_image_draw_line_clipped(200, 0, 0, 200, 50, 100, 0, 300, 1); + imlib_context_set_color(255, 55, 55, 255); + uu = imlib_image_draw_line_clipped(0, 0, 200, 200, 50, 150, 50, 150, 1); up = imlib_updates_append_updates(up, uu); + + imlib_context_set_color(255, 255, 255, 255); + uu = imlib_image_draw_line(305, 25, 20, 200, 1); + up = imlib_updates_append_updates(up, uu); + imlib_context_set_color(255, 55, 55, 255); + uu = imlib_image_draw_line_clipped(305, 25, 20, 200, 50, 150, 50, 150, 1); + up = imlib_updates_append_updates(up, uu); + + imlib_context_set_color(255, 255, 255, 255); + uu = imlib_image_draw_line(100, 5, 100, 205, 1); + up = imlib_updates_append_updates(up, uu); + imlib_context_set_color(255, 55, 55, 255); + uu = imlib_image_draw_line_clipped(100, 5, 100, 205, 50, 150, 50, 150, 1); + up = imlib_updates_append_updates(up, uu); + + imlib_context_set_color(255, 255, 255, 255); + uu = imlib_image_draw_line(275, 5, 20, 100, 1); + up = imlib_updates_append_updates(up, uu); + imlib_context_set_color(255, 55, 55, 255); + uu = imlib_image_draw_line_clipped(275, 5, 20, 100, 50, 150, 50, 150, 1); + up = imlib_updates_append_updates(up, uu); + + /* test rectangle clipping */ + imlib_context_set_color(255, 255, 255, 255); + imlib_image_draw_rectangle(70,90,20,20); + imlib_context_set_color(255, 55, 55, 255); + imlib_image_draw_rectangle_clipped(70,90,20,20,50, 150, 50, 150); + up = imlib_update_append_rect(up, 70,90,20,20); + + imlib_context_set_color(255, 255, 255, 255); + imlib_image_draw_rectangle(115,70,60,30); + imlib_context_set_color(255, 55, 55, 255); + imlib_image_draw_rectangle_clipped(115,70,60,30,50, 150, 50, 150); + up = imlib_update_append_rect(up, 115,70,60,30); + + imlib_context_set_color(255, 255, 255, 255); + imlib_image_draw_rectangle(30,120,50,50); + imlib_context_set_color(255, 55, 55, 255); + imlib_image_draw_rectangle_clipped(30,120,50,50,50, 150, 50, 150); + up = imlib_update_append_rect(up, 30,120,50,50); + } { static Imlib_Color_Range rg = NULL;