libart.pp 16 KB

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