1unit libart;
2
3{$PACKRECORDS C}
4{$mode objfpc}
5
6interface
7
8const
9 libartdll='art_lgpl';
10
11type
12  PPlongint = ^Plongint;
13
14  Part_u8 = ^art_u8;
15  art_u8 = Byte;
16  Part_u16 = ^art_u16;
17  art_u16 = word;
18  Part_u32 = ^art_u32;
19  art_u32 = longword;
20  PArtUtaBbox = ^TArtUtaBbox;
21  TArtUtaBbox = art_u32;
22
23  Part_boolean = ^art_boolean;
24  art_boolean = boolean;
25
26  Taffine_array = array[0..5] of double;
27  Taffine_string = array[0..127] of char;
28
29  TArtPathcode = (ART_MOVETO,ART_MOVETO_OPEN,ART_CURVETO,ART_LINETO,ART_END);
30  TArtFilterLevel = (ART_FILTER_NEAREST,ART_FILTER_TILES,ART_FILTER_BILINEAR,ART_FILTER_HYPER);
31  TArtPathStrokeJoinType = (ART_PATH_STROKE_JOIN_MITER,ART_PATH_STROKE_JOIN_ROUND,ART_PATH_STROKE_JOIN_BEVEL);
32  TArtPathStrokeCapType = (ART_PATH_STROKE_CAP_BUTT,ART_PATH_STROKE_CAP_ROUND,ART_PATH_STROKE_CAP_SQUARE);
33  TArtWindRule = (ART_WIND_RULE_NONZERO,ART_WIND_RULE_INTERSECT,ART_WIND_RULE_ODDEVEN,ART_WIND_RULE_POSITIVE);
34  TArtPixFormat = (ART_PIX_RGB);
35
36  TArtDestroyNotify = procedure (func_data:pointer; data:pointer);cdecl;
37
38  (* Art Point *)
39  PArtPoint = ^TArtPoint;
40  TArtPoint = record
41    x : double;
42    y : double;
43  end;
44
45  (* Art Double Rect *)
46  PArtDRect = ^TArtDRect;
47  TArtDRect = record
48    x0 : double;
49    y0 : double;
50    x1 : double;
51    y1 : double;
52  end;
53
54  (* Art Longint Rect *)
55  PArtIRect = ^TArtIRect;
56  TArtIRect = record
57    x0 : longint;
58    y0 : longint;
59    x1 : longint;
60    y1 : longint;
61  end;
62
63  (* Art Bezier Path *)
64  PArtBpath = ^TArtBpath;
65  TArtBpath = record
66    code : TArtPathcode;
67    x1 : double;
68    y1 : double;
69    x2 : double;
70    y2 : double;
71    x3 : double;
72    y3 : double;
73  end;
74
75  PPArtVpath = ^PArtVpath;
76  PArtVpath = ^TArtVpath;
77  TArtVpath = record
78     code : TArtPathcode;
79     x : double;
80     y : double;
81  end;
82
83  PArtVpathDash = ^TArtVpathDash;
84  TArtVpathDash = record
85    offset : double;
86    n_dash : longint;
87    dash : Pdouble;
88  end;
89
90  PArtAlphaGamma = ^TArtAlphaGamma;
91  TArtAlphaGamma = record
92    gamma : double;
93    invtable_size : longint;
94    table : array[0..255] of longint;
95    invtable : array[0..0] of art_u8;
96  end;
97
98  PArtSVPSeg = ^TArtSVPSeg;
99  TArtSVPSeg = record
100    n_points : longint;
101    dir : longint;
102    bbox : TArtDRect;
103    points : PArtPoint;
104  end;
105
106  PPArtSVP = ^PArtSVP;
107  PArtSVP = ^TArtSVP;
108  TArtSVP = record
109    n_segs : longint;
110    segs : array[0..0] of TArtSVPSeg;
111  end;
112
113  PArtSVPRenderAAStep = ^TArtSVPRenderAAStep;
114  TArtSVPRenderAAStep = record
115    x : longint;
116    delta : longint;
117  end;
118
119  PArtPixBuf = ^TArtPixBuf;
120  TArtPixBuf = record
121    format : TArtPixFormat;
122    n_channels : longint;
123    has_alpha : longint;
124    bits_per_sample : longint;
125    pixels : Part_u8;
126    width : longint;
127    height : longint;
128    rowstride : longint;
129    destroy_data : pointer;
130    destroy : TArtDestroyNotify;
131  end;
132
133  PArtUta = ^TArtUta;
134  TArtUta = record
135    x0 : longint;
136    y0 : longint;
137    width : longint;
138    height : longint;
139    utiles : PArtUtaBbox;
140  end;
141
142  Tart_svp_render_aa_callback = procedure (callback_data:pointer; y:longint; start:longint; steps:PArtSVPRenderAAStep; n_steps:longint); cdecl;
143
144const
145   ART_FALSE = FALSE;
146   ART_TRUE = TRUE;
147   M_PI = 3.14159265358979323846;
148   M_SQRT2 = 1.41421356237309504880;
149
150const
151   ART_UTILE_SHIFT = 5;
152   ART_UTILE_SIZE = 1 shl ART_UTILE_SHIFT;
153
154procedure art_die(fmt:Pchar; args:array of const);cdecl;external libartdll name 'art_die';
155procedure art_warn(fmt:Pchar; args:array of const);cdecl;external libartdll name 'art_warn';
156
157(* ART longint Rect *)
158procedure art_irect_copy(dest:PArtIRect; src:PArtIRect);cdecl;external libartdll name 'art_irect_copy';
159procedure art_irect_union(dest:PArtIRect; src1:PArtIRect; src2:PArtIRect);cdecl;external libartdll name 'art_irect_union';
160procedure art_irect_intersect(dest:PArtIRect; src1:PArtIRect; src2:PArtIRect);cdecl;external libartdll name 'art_irect_intersect';
161function art_irect_empty(src:PArtIRect):longint;cdecl;external libartdll name 'art_irect_empty';
162
163(* ART double Rect *)
164procedure art_drect_copy(dest:PArtDRect; src:PArtDRect);cdecl;external libartdll name 'art_drect_copy';
165procedure art_drect_union(dest:PArtDRect; src1:PArtDRect; src2:PArtDRect);cdecl;external libartdll name 'art_drect_union';
166procedure art_drect_intersect(dest:PArtDRect; src1:PArtDRect; src2:PArtDRect);cdecl;external libartdll name 'art_drect_intersect';
167function art_drect_empty(src:PArtDRect):longint;cdecl;external libartdll name 'art_drect_empty';
168procedure art_drect_affine_transform(dst:PArtDRect; src:PArtDRect; matrix:Taffine_array);cdecl;external libartdll name 'art_drect_affine_transform';
169procedure art_drect_to_irect(dst:PArtIRect; src:PArtDRect);cdecl;external libartdll name 'art_drect_to_irect';
170procedure art_drect_svp(bbox:PArtDRect; svp:PArtSVP);cdecl;external libartdll name 'art_drect_svp';
171procedure art_drect_svp_union(bbox:PArtDRect; svp:PArtSVP);cdecl;external libartdll name 'art_drect_svp_union';
172
173(* ART bezier's *)
174function art_bezier_to_vec(x0:double; y0:double; x1:double; y1:double; x2:double;
175           y2:double; x3:double; y3:double; p:PArtPoint; level:longint):PArtPoint;cdecl;external libartdll name 'art_bezier_to_vec';
176function art_bez_path_to_vec(bez:PArtBpath; flatness:double):PArtVpath;cdecl;external libartdll name 'art_bez_path_to_vec';
177function art_bpath_affine_transform(src:PArtBpath; matrix:Taffine_array):PArtBpath;cdecl;external libartdll name 'art_bpath_affine_transform';
178
179(* ART affine transformations *)
180procedure art_affine_point(dst:PArtPoint; src:PArtPoint; affine:Taffine_array);cdecl;external libartdll name 'art_affine_point';
181procedure art_affine_invert(dst_affine:Taffine_array; src_affine:Taffine_array);cdecl;external libartdll name 'art_affine_invert';
182procedure art_affine_flip(dst_affine:Taffine_array; src_affine:Taffine_array; horz:longint; vert:longint);cdecl;external libartdll name 'art_affine_flip';
183procedure art_affine_to_string(str:Taffine_string; src:Taffine_array);cdecl;external libartdll name 'art_affine_to_string';
184procedure art_affine_multiply(dst:Taffine_array; src1:Taffine_array; src2:Taffine_array);cdecl;external libartdll name 'art_affine_multiply';
185procedure art_affine_identity(dst:Taffine_array);cdecl;external libartdll name 'art_affine_identity';
186procedure art_affine_scale(dst:Taffine_array; sx:double; sy:double);cdecl;external libartdll name 'art_affine_scale';
187procedure art_affine_rotate(dst:Taffine_array; theta:double);cdecl;external libartdll name 'art_affine_rotate';
188procedure art_affine_shear(dst:Taffine_array; theta:double);cdecl;external libartdll name 'art_affine_shear';
189procedure art_affine_translate(dst:Taffine_array; tx:double; ty:double);cdecl;external libartdll name 'art_affine_translate';
190function art_affine_expansion(src:Taffine_array):double;cdecl;external libartdll name 'art_affine_expansion';
191function art_affine_rectilinear(src:Taffine_array):longint;cdecl;external libartdll name 'art_affine_rectilinear';
192function art_affine_equal(matrix1:Taffine_array; matrix2:Taffine_array):longint;cdecl;external libartdll name 'art_affine_equal';
193
194(* ART alphagamma *)
195function art_alphagamma_new(gamma:double):PArtAlphaGamma;cdecl;external libartdll name 'art_alphagamma_new';
196procedure art_alphagamma_free(alphagamma:PArtAlphaGamma);cdecl;external libartdll name 'art_alphagamma_free';
197
198
199(* ART SVP *)
200function art_svp_add_segment(p_vp:PPArtSVP; pn_segs_max:Plongint; pn_points_max:PPlongint; n_points:longint; dir:longint;
201           points:PArtPoint; bbox:PArtDRect):longint;cdecl;external libartdll name 'art_svp_add_segment';
202procedure art_svp_free(svp:PArtSVP);cdecl;external libartdll name 'art_svp_free';
203function art_svp_seg_compare(s1:pointer; s2:pointer):longint;cdecl;external libartdll name 'art_svp_seg_compare';
204
205function art_svp_union(svp1:PArtSVP; svp2:PArtSVP):PArtSVP;cdecl;external libartdll name 'art_svp_union';
206function art_svp_intersect(svp1:PArtSVP; svp2:PArtSVP):PArtSVP;cdecl;external libartdll name 'art_svp_intersect';
207function art_svp_diff(svp1:PArtSVP; svp2:PArtSVP):PArtSVP;cdecl;external libartdll name 'art_svp_diff';
208function art_svp_minus(svp1:PArtSVP; svp2:PArtSVP):PArtSVP;cdecl;external libartdll name 'art_svp_minus';
209
210function art_svp_point_wind(svp:PArtSVP; x:double; y:double):longint;cdecl;external libartdll name 'art_svp_point_wind';
211function art_svp_point_dist(svp:PArtSVP; x:double; y:double):double;cdecl;external libartdll name 'art_svp_point_dist';
212
213procedure art_svp_render_aa(svp:PArtSVP; x0:longint; y0:longint; x1:longint; y1:longint;
214            callback: Tart_svp_render_aa_callback; callback_data:pointer);cdecl;external libartdll name 'art_svp_render_aa';
215
216function art_svp_from_vpath(vpath:PArtVpath):PArtSVP;cdecl;external libartdll name 'art_svp_from_vpath';
217
218function art_svp_vpath_stroke(vpath:PArtVpath; join:TArtPathStrokeJoinType; cap:TArtPathStrokeCapType; line_width:double; miter_limit:double;
219           flatness:double):PArtSVP;cdecl;external libartdll name 'art_svp_vpath_stroke';
220function art_svp_vpath_stroke_raw(vpath:PArtVpath; join:TArtPathStrokeJoinType; cap:TArtPathStrokeCapType; line_width:double; miter_limit:double;
221           flatness:double):PArtVpath;cdecl;external libartdll name 'art_svp_vpath_stroke_raw';
222
223function art_svp_uncross(vp:PArtSVP):PArtSVP;cdecl;external libartdll name 'art_svp_uncross';
224function art_svp_rewind_uncrossed(vp:PArtSVP; rule:TArtWindRule):PArtSVP;cdecl;external libartdll name 'art_svp_rewind_uncrossed';
225
226(* ART GRAY SVP *)
227procedure art_gray_svp_aa(svp:PArtSVP; x0:longint; y0:longint; x1:longint; y1:longint;
228            buf:Part_u8; rowstride:longint);cdecl;external libartdll name 'art_gray_svp_aa';
229
230(* ART VPATH *)
231procedure art_vpath_add_point(p_vpath:PPArtVpath; pn_points:Plongint; pn_points_max:Plongint; code:TArtPathcode; x:double;
232  y:double);cdecl;external libartdll name 'art_vpath_add_point';
233function art_vpath_new_circle(x:double; y:double; r:double):PArtVpath;cdecl;external libartdll name 'art_vpath_new_circle';
234function art_vpath_affine_transform(src:PArtVpath; matrix:Taffine_array):PArtVpath;cdecl;external libartdll name 'art_vpath_affine_transform';
235procedure art_vpath_bbox_drect(vec:PArtVpath; drect:PArtDRect);cdecl;external libartdll name 'art_vpath_bbox_drect';
236procedure art_vpath_bbox_irect(vec:PArtVpath; irect:PArtIRect);cdecl;external libartdll name 'art_vpath_bbox_irect';
237function art_vpath_perturb(src:PArtVpath):PArtVpath;cdecl;external libartdll name 'art_vpath_perturb';
238function art_vpath_from_svp(svp:PArtSVP):PArtVpath;cdecl;external libartdll name 'art_vpath_from_svp';
239function art_vpath_dash(vpath:PArtVpath; dash:PArtVpathDash):PArtVpath;cdecl;external libartdll name 'art_vpath_dash';
240
241(* ART PIXBUF *)
242function art_pixbuf_new_rgb(pixels:Part_u8; width:longint; height:longint; rowstride:longint):PArtPixBuf;cdecl;external libartdll name 'art_pixbuf_new_rgb';
243function art_pixbuf_new_rgba(pixels:Part_u8; width:longint; height:longint; rowstride:longint):PArtPixBuf;cdecl;external libartdll name 'art_pixbuf_new_rgba';
244function art_pixbuf_new_const_rgb(pixels:Part_u8; width:longint; height:longint; rowstride:longint):PArtPixBuf;cdecl;external libartdll name 'art_pixbuf_new_const_rgb';
245function art_pixbuf_new_const_rgba(pixels:Part_u8; width:longint; height:longint; rowstride:longint):PArtPixBuf;cdecl;external libartdll name 'art_pixbuf_new_const_rgba';
246function art_pixbuf_new_rgb_dnotify(pixels:Part_u8; width:longint; height:longint; rowstride:longint; dfunc_data:pointer;
247           dfunc:TArtDestroyNotify):PArtPixBuf;cdecl;external libartdll name 'art_pixbuf_new_rgb_dnotify';
248function art_pixbuf_new_rgba_dnotify(pixels:Part_u8; width:longint; height:longint; rowstride:longint; dfunc_data:pointer;
249           dfunc:TArtDestroyNotify):PArtPixBuf;cdecl;external libartdll name 'art_pixbuf_new_rgba_dnotify';
250procedure art_pixbuf_free(pixbuf:PArtPixBuf);cdecl;external libartdll name 'art_pixbuf_free';
251procedure art_pixbuf_free_shallow(pixbuf:PArtPixBuf);cdecl;external libartdll name 'art_pixbuf_free_shallow';
252function art_pixbuf_duplicate(pixbuf:PArtPixBuf):PArtPixBuf;cdecl;external libartdll name 'art_pixbuf_duplicate';
253
254(* ART RGB *)
255procedure art_rgb_fill_run(buf:Part_u8; r:art_u8; g:art_u8; b:art_u8; n:longint);cdecl;external libartdll name 'art_rgb_fill_run';
256procedure art_rgb_run_alpha(buf:Part_u8; r:art_u8; g:art_u8; b:art_u8; alpha:longint; n:longint);cdecl;external libartdll name 'art_rgb_run_alpha';
257
258procedure art_rgb_affine(dst:Part_u8; x0:longint; y0:longint; x1:longint; y1:longint;
259            dst_rowstride:longint; src:Part_u8; src_width:longint; src_height:longint; src_rowstride:longint;
260            affine:Taffine_array; level:TArtFilterLevel; alphagamma:PArtAlphaGamma);cdecl;external libartdll name 'art_rgb_affine';
261
262procedure art_rgb_bitmap_affine(dst:Part_u8; x0:longint; y0:longint; x1:longint; y1:longint;
263            dst_rowstride:longint; src:Part_u8; src_width:longint; src_height:longint; src_rowstride:longint;
264            rgba:art_u32; affine:Taffine_array; level:TArtFilterLevel; alphagamma:PArtAlphaGamma);cdecl;external libartdll name 'art_rgb_bitmap_affine';
265
266procedure art_rgb_pixbuf_affine(dst:Part_u8; x0:longint; y0:longint; x1:longint; y1:longint;
267            dst_rowstride:longint; pixbuf:PArtPixBuf; affine:Taffine_array; level:TArtFilterLevel; alphagamma:PArtAlphaGamma);cdecl;external libartdll name 'art_rgb_pixbuf_affine';
268
269procedure art_rgb_rgba_affine(dst:Part_u8; x0:longint; y0:longint; x1:longint; y1:longint;
270            dst_rowstride:longint; src:Part_u8; src_width:longint; src_height:longint; src_rowstride:longint;
271            affine:Taffine_array; level:TArtFilterLevel; alphagamma:PArtAlphaGamma);cdecl;external libartdll name 'art_rgb_rgba_affine';
272
273procedure art_rgb_svp_aa(svp:PArtSVP; x0:longint; y0:longint; x1:longint; y1:longint;
274            fg_color:art_u32; bg_color:art_u32; buf:Part_u8; rowstride:longint; alphagamma:PArtAlphaGamma);cdecl;external libartdll name 'art_rgb_svp_aa';
275procedure art_rgb_svp_alpha(svp:PArtSVP; x0:longint; y0:longint; x1:longint; y1:longint;
276            rgba:art_u32; buf:Part_u8; rowstride:longint; alphagamma:PArtAlphaGamma);cdecl;external libartdll name 'art_rgb_svp_alpha';
277
278(* ART UTA *)
279function art_uta_new(x0:longint; y0:longint; x1:longint; y1:longint):PArtUta;cdecl;external libartdll name 'art_uta_new';
280function art_uta_new_coords(x0:longint; y0:longint; x1:longint; y1:longint):PArtUta;cdecl;external libartdll name 'art_uta_new_coords';
281procedure art_uta_free(uta:PArtUta);cdecl;external libartdll name 'art_uta_free';
282
283function art_uta_union(uta1:PArtUta; uta2:PArtUta):PArtUta;cdecl;external libartdll name 'art_uta_union';
284function art_uta_from_irect(bbox:PArtIRect):PArtUta;cdecl;external libartdll name 'art_uta_from_irect';
285function art_uta_from_svp(svp:PArtSVP):PArtUta;cdecl;external libartdll name 'art_uta_from_svp';
286function art_uta_from_vpath(vec:PArtVpath):PArtUta;cdecl;external libartdll name 'art_uta_from_vpath';
287procedure art_uta_add_line(uta:PArtUta; x0:double; y0:double; x1:double; y1:double;
288            rbuf:Plongint; rbuf_rowstride:longint);cdecl;external libartdll name 'art_uta_add_line';
289function art_rect_list_from_uta(uta:PArtUta; max_width:longint; max_height:longint; p_nrects:Plongint):PArtIRect;cdecl;external libartdll name 'art_rect_list_from_uta';
290
291function ART_UTA_BBOX_CONS(x0,y0,x1,y1 : longint) : longint;
292function ART_UTA_BBOX_X0(ub : longint) : longint;
293function ART_UTA_BBOX_Y0(ub : longint) : longint;
294function ART_UTA_BBOX_X1(ub : longint) : longint;
295function ART_UTA_BBOX_Y1(ub : longint) : longint;
296
297implementation
298
299function ART_UTA_BBOX_CONS(x0,y0,x1,y1 : longint) : longint;
300begin
301   ART_UTA_BBOX_CONS:=(((x0 shl 24) or (y0 shl 16)) or (x1 shl 8)) or y1;
302end;
303
304function ART_UTA_BBOX_X0(ub : longint) : longint;
305begin
306   ART_UTA_BBOX_X0:=ub shr 24;
307end;
308
309function ART_UTA_BBOX_Y0(ub : longint) : longint;
310begin
311   ART_UTA_BBOX_Y0:=(ub shr 16) and $ff;
312end;
313
314function ART_UTA_BBOX_X1(ub : longint) : longint;
315begin
316   ART_UTA_BBOX_X1:=(ub shr 8) and $ff;
317end;
318
319function ART_UTA_BBOX_Y1(ub : longint) : longint;
320begin
321   ART_UTA_BBOX_Y1:=ub and $ff;
322end;
323
324end.
325