summaryrefslogtreecommitdiff
path: root/src/lib/rgbadraw.h
blob: 9dc35b5f22edf63f54a9a10245723e52d613e370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef __RGBADRAW
#define __RGBADRAW 1

#define IN_SEGMENT(x, sx, sw) \
((unsigned)((x) - (sx)) < (sw))

#define IN_RANGE(x, y, w, h) \
( ((unsigned)(x) < (w)) && ((unsigned)(y) < (h)) )

#define IN_RECT(x, y, rx, ry, rw, rh) \
( ((unsigned)((x) - (rx)) < (rw)) && ((unsigned)((y) - (ry)) < (rh)) )

#define CLIP_RECT_TO_RECT(x, y, w, h, rx, ry, rw, rh) \
{								\
  int   _t0, _t1;						\
								\
  _t0 = MAX(x, (rx));						\
  _t1 = MIN(x + w, (rx) + (rw));				\
  x = _t0;							\
  w = _t1 - _t0;						\
  _t0 = MAX(y, (ry));						\
  _t1 = MIN(y + h, (ry) + (rh));				\
  y = _t0;							\
  h = _t1 - _t0;						\
}

#define DIV_255(a, x, tmp) \
do {                           \
 tmp = (x) + 0x80;             \
 a = (tmp + (tmp >> 8)) >> 8;  \
} while (0)

#define MULT(na, a0, a1, tmp) \
  DIV_255(na, (a0) * (a1), tmp)


typedef struct _imlib_point ImlibPoint;

struct _imlib_point
{
   int x, y;
};

typedef struct _imlib_rectangle Imlib_Rectangle;

struct _imlib_rectangle
{
   int x, y, w, h;
};

typedef struct _imlib_polygon _ImlibPoly;
typedef _ImlibPoly *ImlibPoly;

struct _imlib_polygon
{
   ImlibPoint *points;
   int pointcount;
   int  lx, rx;
   int  ty, by;
};

/* image related operations: in rgbadraw.c */

__hidden void __imlib_FlipImageHoriz(ImlibImage * im);
__hidden void __imlib_FlipImageVert(ImlibImage * im);
__hidden void __imlib_FlipImageBoth(ImlibImage * im);
__hidden void __imlib_FlipImageDiagonal(ImlibImage * im, int direction);
__hidden void __imlib_BlurImage(ImlibImage * im, int rad);
__hidden void __imlib_SharpenImage(ImlibImage * im, int rad);
__hidden void __imlib_TileImageHoriz(ImlibImage * im);
__hidden void __imlib_TileImageVert(ImlibImage * im);

__hidden void __imlib_copy_alpha_data(ImlibImage * src, ImlibImage * dst, int x, int y,
                             int w, int h, int nx, int ny);

__hidden void __imlib_copy_image_data(ImlibImage * im, int x, int y, int w, int h,
                             int nx, int ny);


/* point and line drawing: in line.c */

__hidden ImlibUpdate *
__imlib_Point_DrawToImage(int x, int y, DATA32 color,
			  ImlibImage *im, int clx, int cly, int clw, int clh,
			  ImlibOp op, char blend, char make_updates);

__hidden ImlibUpdate *
__imlib_Line_DrawToImage(int x0, int y0, int x1, int y1, DATA32 color,
			 ImlibImage *im, int clx, int cly, int clw, int clh,
			 ImlibOp op, char blend, char anti_alias,
			 char make_updates);


/* rectangle drawing and filling: in rectangle.c */

__hidden void
__imlib_Rectangle_DrawToImage(int xc, int yc, int w, int h, DATA32 color, 
			      ImlibImage *im, int clx, int cly, int clw, int clh,
			      ImlibOp op, char blend);

__hidden void
__imlib_Rectangle_FillToImage(int xc, int yc, int w, int h, DATA32 color, 
			      ImlibImage *im, int clx, int cly, int clw, int clh,
			      ImlibOp op, char blend);


/* ellipse drawing and filling: in ellipse.c */

__hidden void
__imlib_Ellipse_DrawToImage(int xc, int yc, int a, int b, DATA32 color, 
			    ImlibImage *im, int clx, int cly, int clw, int clh,
			    ImlibOp op, char blend, char anti_alias);

__hidden void
__imlib_Ellipse_FillToImage(int xc, int yc, int a, int b, DATA32 color, 
			    ImlibImage *im, int clx, int cly, int clw, int clh,
			    ImlibOp op, char blend, char anti_alias);


/* polygon handling functions: in polygon.c */

__hidden ImlibPoly __imlib_polygon_new(void);
__hidden void __imlib_polygon_free(ImlibPoly poly);
__hidden void __imlib_polygon_add_point(ImlibPoly poly, int x, int y);
__hidden unsigned char __imlib_polygon_contains_point(ImlibPoly poly, int x, int y);
__hidden void __imlib_polygon_get_bounds(ImlibPoly poly, int *px1, int *py1, int *px2, int *py2);


/* polygon drawing and filling: in polygon.c */

__hidden void
__imlib_Polygon_DrawToImage(ImlibPoly poly, char closed, DATA32 color,
			    ImlibImage *im, int clx, int cly, int clw, int clh,
			    ImlibOp op, char blend, char anti_alias);
__hidden void
__imlib_Polygon_FillToImage(ImlibPoly poly, DATA32 color,
			    ImlibImage *im, int clx, int cly, int clw, int clh,
			    ImlibOp op, char blend, char anti_alias);


#endif