libart.pp 16 KB

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