1 #ifndef __RGBADRAW 2 #define __RGBADRAW 1 3 4 #include "common.h" 5 #include "updates.h" 6 7 #define IN_SEGMENT(x, sx, sw) \ 8 ((unsigned)((x) - (sx)) < (unsigned)(sw)) 9 10 #define IN_RANGE(x, y, w, h) \ 11 ( ((unsigned)(x) < (unsigned)(w)) && ((unsigned)(y) < (unsigned)(h)) ) 12 13 #define IN_RECT(x, y, rx, ry, rw, rh) \ 14 ( ((unsigned)((x) - (rx)) < (unsigned)(rw)) && \ 15 ((unsigned)((y) - (ry)) < (unsigned)(rh)) ) 16 17 #define CLIP_RECT_TO_RECT(x, y, w, h, rx, ry, rw, rh) \ 18 { \ 19 int _t0, _t1; \ 20 \ 21 _t0 = MAX(x, (rx)); \ 22 _t1 = MIN(x + w, (rx) + (rw)); \ 23 x = _t0; \ 24 w = _t1 - _t0; \ 25 _t0 = MAX(y, (ry)); \ 26 _t1 = MIN(y + h, (ry) + (rh)); \ 27 y = _t0; \ 28 h = _t1 - _t0; \ 29 } 30 31 #define DIV_255(a, x, tmp) \ 32 do { \ 33 tmp = (x) + 0x80; \ 34 a = (tmp + (tmp >> 8)) >> 8; \ 35 } while (0) 36 37 #define MULT(na, a0, a1, tmp) \ 38 DIV_255(na, (a0) * (a1), tmp) 39 40 typedef struct _imlib_point ImlibPoint; 41 42 struct _imlib_point { 43 int x, y; 44 }; 45 46 typedef struct _imlib_rectangle Imlib_Rectangle; 47 48 struct _imlib_rectangle { 49 int x, y, w, h; 50 }; 51 52 typedef struct _imlib_polygon _ImlibPoly; 53 typedef _ImlibPoly *ImlibPoly; 54 55 struct _imlib_polygon { 56 ImlibPoint *points; 57 int pointcount; 58 int lx, rx; 59 int ty, by; 60 }; 61 62 /* image related operations: in rgbadraw.c */ 63 64 void __imlib_FlipImageHoriz(ImlibImage * im); 65 void __imlib_FlipImageVert(ImlibImage * im); 66 void __imlib_FlipImageBoth(ImlibImage * im); 67 void __imlib_FlipImageDiagonal(ImlibImage * im, int direction); 68 void __imlib_BlurImage(ImlibImage * im, int rad); 69 void __imlib_SharpenImage(ImlibImage * im, int rad); 70 void __imlib_TileImageHoriz(ImlibImage * im); 71 void __imlib_TileImageVert(ImlibImage * im); 72 73 void __imlib_copy_alpha_data(ImlibImage * src, ImlibImage * dst, 74 int x, int y, int w, int h, 75 int nx, int ny); 76 77 void __imlib_copy_image_data(ImlibImage * im, int x, int y, 78 int w, int h, int nx, int ny); 79 80 /* point and line drawing: in line.c */ 81 82 ImlibUpdate *__imlib_Point_DrawToImage(int x, int y, DATA32 color, 83 ImlibImage * im, 84 int clx, int cly, 85 int clw, int clh, 86 ImlibOp op, char blend, 87 char make_updates); 88 89 ImlibUpdate *__imlib_Line_DrawToImage(int x0, int y0, int x1, int y1, 90 DATA32 color, ImlibImage * im, 91 int clx, int cly, int clw, int clh, 92 ImlibOp op, char blend, 93 char anti_alias, 94 char make_updates); 95 96 /* rectangle drawing and filling: in rectangle.c */ 97 98 void __imlib_Rectangle_DrawToImage(int xc, int yc, int w, int h, 99 DATA32 color, ImlibImage * im, 100 int clx, int cly, 101 int clw, int clh, 102 ImlibOp op, char blend); 103 104 void __imlib_Rectangle_FillToImage(int xc, int yc, int w, int h, 105 DATA32 color, ImlibImage * im, 106 int clx, int cly, 107 int clw, int clh, 108 ImlibOp op, char blend); 109 110 /* ellipse drawing and filling: in ellipse.c */ 111 112 void __imlib_Ellipse_DrawToImage(int xc, int yc, int a, int b, 113 DATA32 color, ImlibImage * im, 114 int clx, int cly, 115 int clw, int clh, 116 ImlibOp op, char blend, 117 char anti_alias); 118 119 void __imlib_Ellipse_FillToImage(int xc, int yc, int a, int b, 120 DATA32 color, ImlibImage * im, 121 int clx, int cly, 122 int clw, int clh, 123 ImlibOp op, char blend, 124 char anti_alias); 125 126 /* polygon handling functions: in polygon.c */ 127 128 ImlibPoly __imlib_polygon_new(void); 129 void __imlib_polygon_free(ImlibPoly poly); 130 void __imlib_polygon_add_point(ImlibPoly poly, int x, int y); 131 unsigned char __imlib_polygon_contains_point(ImlibPoly poly, 132 int x, int y); 133 void __imlib_polygon_get_bounds(ImlibPoly poly, 134 int *px1, int *py1, 135 int *px2, int *py2); 136 137 /* polygon drawing and filling: in polygon.c */ 138 139 void __imlib_Polygon_DrawToImage(ImlibPoly poly, char closed, 140 DATA32 color, ImlibImage * im, 141 int clx, int cly, 142 int clw, int clh, 143 ImlibOp op, char blend, 144 char anti_alias); 145 void __imlib_Polygon_FillToImage(ImlibPoly poly, DATA32 color, 146 ImlibImage * im, 147 int clx, int cly, 148 int clw, int clh, 149 ImlibOp op, char blend, 150 char anti_alias); 151 152 #endif 153