2
0

imlib.pp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. {
  2. Imlib library
  3. Copyright (C) 1998 By The Rasterman (Carsten Haitzler)
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. **********************************************************************}
  17. {$IFNDEF FPC_DOTTEDUNITS}
  18. unit Imlib;
  19. {$ENDIF FPC_DOTTEDUNITS}
  20. interface
  21. {$PACKRECORDS C}
  22. {$mode objfpc}
  23. {$IFDEF FPC_DOTTEDUNITS}
  24. Uses Api.X11.X, Api.X11.Xlib, Api.X11.Xutil;
  25. {$ELSE FPC_DOTTEDUNITS}
  26. Uses X, Xlib, XUtil;
  27. {$ENDIF FPC_DOTTEDUNITS}
  28. const
  29. {$ifndef os2}
  30. Imlibdll='Imlib';
  31. {$else}
  32. Imlibdll='Imlib195';
  33. {$endif}
  34. Type
  35. PImlibBorder = ^TImlibBorder;
  36. TImlibBorder = record
  37. left : longint;
  38. right : longint;
  39. top : longint;
  40. bottom : longint;
  41. end;
  42. PImlibColor = ^TImlibColor;
  43. TImlibColor = record
  44. r : longint;
  45. g : longint;
  46. b : longint;
  47. pixel : longint;
  48. end;
  49. PImlibColorModifier = ^TImlibColorModifier;
  50. TImlibColorModifier = record
  51. gamma : longint;
  52. brightness : longint;
  53. contrast : longint;
  54. end;
  55. PImlibImage = ^TImlibImage;
  56. TImlibImage = record
  57. rgb_width : longint;
  58. rgb_height : longint;
  59. rgb_data : Pbyte;
  60. alpha_data : Pbyte;
  61. filename : PAnsiChar;
  62. width : longint;
  63. height : longint;
  64. shape_color : TImlibColor;
  65. border : TImlibBorder;
  66. pixmap : TPixmap;
  67. shape_mask : TPixmap;
  68. cache : AnsiChar;
  69. mods : TImlibColorModifier;
  70. rmod : TImlibColorModifier;
  71. gmod : TImlibColorModifier;
  72. bmod : TImlibColorModifier;
  73. rmap : array[0..255] of byte;
  74. gmap : array[0..255] of byte;
  75. bmap : array[0..255] of byte;
  76. end;
  77. Pxdata = ^Txdata;
  78. Txdata = record
  79. disp : PDisplay;
  80. screen : longint;
  81. root : TWindow;
  82. visual : PVisual;
  83. depth : longint;
  84. render_depth : longint;
  85. root_cmap : TColormap;
  86. shm : AnsiChar;
  87. shmp : AnsiChar;
  88. shm_event : longint;
  89. last_xim : PXImage;
  90. last_sxim : PXImage;
  91. last_shminfo : Pointer;//XShmSegmentInfo;
  92. last_sshminfo :Pointer;//XShmSegmentInfo;
  93. base_window : TWindow;
  94. byte_order : longint;
  95. bit_order : longint;
  96. end;
  97. PImlibData = ^TImlibData;
  98. TImlibData = record
  99. num_colors : longint;
  100. palette : PImlibColor;
  101. palette_orig : PImlibColor;
  102. fast_rgb : Pbyte;
  103. fast_err : Plongint;
  104. fast_erg : Plongint;
  105. fast_erb : Plongint;
  106. render_type : longint;
  107. max_shm : longint;
  108. x : TXdata;
  109. byte_order : longint;
  110. cache : record
  111. on_image : AnsiChar;
  112. size_image : longint;
  113. num_image : longint;
  114. used_image : longint;
  115. image : Pointer;//image_cache;
  116. on_pixmap : AnsiChar;
  117. size_pixmap : longint;
  118. num_pixmap : longint;
  119. used_pixmap : longint;
  120. pixmap : Pointer;//pixmap_cache;
  121. end;
  122. fastrend : AnsiChar;
  123. hiq : AnsiChar;
  124. mods : TImlibColorModifier;
  125. rmod : TImlibColorModifier;
  126. gmod : TImlibColorModifier;
  127. bmod : TImlibColorModifier;
  128. rmap : array[0..255] of byte;
  129. gmap : array[0..255] of byte;
  130. bmap : array[0..255] of byte;
  131. fallback : AnsiChar;
  132. ordered_dither : AnsiChar;
  133. end;
  134. PImlibSaveInfo = ^TImlibSaveInfo;
  135. TImlibSaveInfo = record
  136. quality : longint;
  137. scaling : longint;
  138. xjustification : longint;
  139. yjustification : longint;
  140. page_size : longint;
  141. color : AnsiChar;
  142. end;
  143. PImlibInitParams = ^TImlibInitParams;
  144. TImlibInitParams = record
  145. flags : longint;
  146. visualid : longint;
  147. palettefile : PAnsiChar;
  148. sharedmem : AnsiChar;
  149. sharedpixmaps : AnsiChar;
  150. paletteoverride : AnsiChar;
  151. remap : AnsiChar;
  152. fastrender : AnsiChar;
  153. hiquality : AnsiChar;
  154. dither : AnsiChar;
  155. imagecachesize : longint;
  156. pixmapcachesize : longint;
  157. cmap : TColormap;
  158. end;
  159. const
  160. PARAMS_VISUALID = 1 shl 0;
  161. PARAMS_PALETTEFILE = 1 shl 1;
  162. PARAMS_SHAREDMEM = 1 shl 2;
  163. PARAMS_SHAREDPIXMAPS = 1 shl 3;
  164. PARAMS_PALETTEOVERRIDE = 1 shl 4;
  165. PARAMS_REMAP = 1 shl 5;
  166. PARAMS_FASTRENDER = 1 shl 6;
  167. PARAMS_HIQUALITY = 1 shl 7;
  168. PARAMS_DITHER = 1 shl 8;
  169. PARAMS_IMAGECACHESIZE = 1 shl 9;
  170. PARAMS_PIXMAPCACHESIZE = 1 shl 10;
  171. PAGE_SIZE_EXECUTIVE = 0;
  172. PAGE_SIZE_LETTER = 1;
  173. PAGE_SIZE_LEGAL = 2;
  174. PAGE_SIZE_A4 = 3;
  175. PAGE_SIZE_A3 = 4;
  176. PAGE_SIZE_A5 = 5;
  177. PAGE_SIZE_FOLIO = 6;
  178. RT_PLAIN_PALETTE = 0;
  179. RT_PLAIN_PALETTE_FAST = 1;
  180. RT_DITHER_PALETTE = 2;
  181. RT_DITHER_PALETTE_FAST = 3;
  182. RT_PLAIN_TRUECOL = 4;
  183. RT_DITHER_TRUECOL = 5;
  184. function Imlib_init(disp:PDisplay):PImlibData;cdecl;external imlibdll name 'Imlib_init';
  185. function Imlib_init_with_params(disp:PDisplay; p:PImlibInitParams):PImlibData;cdecl;external imlibdll name 'Imlib_init_with_params';
  186. function Imlib_get_render_type(id:PImlibData):longint;cdecl;external imlibdll name 'Imlib_get_render_type';
  187. procedure Imlib_set_render_type(id:PImlibData; rend_type:longint);cdecl;external imlibdll name 'Imlib_set_render_type';
  188. function Imlib_load_colors(id:PImlibData; thefile:PAnsiChar):longint;cdecl;external imlibdll name 'Imlib_load_colors';
  189. function Imlib_load_image(id:PImlibData; thefile:PAnsiChar):PImlibImage;cdecl;external imlibdll name 'Imlib_load_image';
  190. function Imlib_best_color_match(id:PImlibData; r:Plongint; g:Plongint; b:Plongint):longint;cdecl;external imlibdll name 'Imlib_best_color_match';
  191. function Imlib_render(id:PImlibData; image:PImlibImage; width:longint; height:longint):longint;cdecl;external imlibdll name 'Imlib_render';
  192. function Imlib_copy_image(id:PImlibData; image:PImlibImage):TPixmap;cdecl;external imlibdll name 'Imlib_copy_image';
  193. function Imlib_copy_mask(id:PImlibData; image:PImlibImage):TPixmap;cdecl;external imlibdll name 'Imlib_copy_mask';
  194. function Imlib_move_image(id:PImlibData; image:PImlibImage):TPixmap;cdecl;external imlibdll name 'Imlib_move_image';
  195. function Imlib_move_mask(id:PImlibData; image:PImlibImage):TPixmap;cdecl;external imlibdll name 'Imlib_move_mask';
  196. procedure Imlib_destroy_image(id:PImlibData; image:PImlibImage);cdecl;external imlibdll name 'Imlib_destroy_image';
  197. procedure Imlib_kill_image(id:PImlibData; image:PImlibImage);cdecl;external imlibdll name 'Imlib_kill_image';
  198. procedure Imlib_free_colors(id:PImlibData);cdecl;external imlibdll name 'Imlib_free_colors';
  199. procedure Imlib_free_pixmap(id:PImlibData; pixmap:TPixmap);cdecl;external imlibdll name 'Imlib_free_pixmap';
  200. procedure Imlib_get_image_border(id:PImlibData; image:PImlibImage; border:PImlibBorder);cdecl;external imlibdll name 'Imlib_get_image_border';
  201. procedure Imlib_set_image_border(id:PImlibData; image:PImlibImage; border:PImlibBorder);cdecl;external imlibdll name 'Imlib_set_image_border';
  202. procedure Imlib_get_image_shape(id:PImlibData; image:PImlibImage; color:PImlibColor);cdecl;external imlibdll name 'Imlib_get_image_shape';
  203. procedure Imlib_set_image_shape(id:PImlibData; image:PImlibImage; color:PImlibColor);cdecl;external imlibdll name 'Imlib_set_image_shape';
  204. function Imlib_save_image_to_eim(id:PImlibData; image:PImlibImage; thefile:PAnsiChar):longint;cdecl;external imlibdll name 'Imlib_save_image_to_eim';
  205. function Imlib_add_image_to_eim(id:PImlibData; image:PImlibImage; thefile:PAnsiChar):longint;cdecl;external imlibdll name 'Imlib_add_image_to_eim';
  206. function Imlib_save_image_to_ppm(id:PImlibData; image:PImlibImage; thefile:PAnsiChar):longint;cdecl;external imlibdll name 'Imlib_save_image_to_ppm';
  207. function Imlib_load_file_to_pixmap(id:PImlibData; filename:PAnsiChar; pmap:PPixmap; mask:PPixmap):longint;cdecl;external imlibdll name 'Imlib_load_file_to_pixmap';
  208. procedure Imlib_set_image_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_set_image_modifier';
  209. procedure Imlib_set_image_red_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_set_image_red_modifier';
  210. procedure Imlib_set_image_green_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_set_image_green_modifier';
  211. procedure Imlib_set_image_blue_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_set_image_blue_modifier';
  212. procedure Imlib_get_image_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_get_image_modifier';
  213. procedure Imlib_get_image_red_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_get_image_red_modifier';
  214. procedure Imlib_get_image_green_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_get_image_green_modifier';
  215. procedure Imlib_get_image_blue_modifier(id:PImlibData; image:PImlibImage; mods:PImlibColorModifier);cdecl;external imlibdll name 'Imlib_get_image_blue_modifier';
  216. procedure Imlib_set_image_red_curve(id:PImlibData; image:PImlibImage; mods:Pbyte);cdecl;external imlibdll name 'Imlib_set_image_red_curve';
  217. procedure Imlib_set_image_green_curve(id:PImlibData; image:PImlibImage; mods:Pbyte);cdecl;external imlibdll name 'Imlib_set_image_green_curve';
  218. procedure Imlib_set_image_blue_curve(id:PImlibData; image:PImlibImage; mods:Pbyte);cdecl;external imlibdll name 'Imlib_set_image_blue_curve';
  219. procedure Imlib_get_image_red_curve(id:PImlibData; image:PImlibImage; mods:Pbyte);cdecl;external imlibdll name 'Imlib_get_image_red_curve';
  220. procedure Imlib_get_image_green_curve(id:PImlibData; image:PImlibImage; mods:Pbyte);cdecl;external imlibdll name 'Imlib_get_image_green_curve';
  221. procedure Imlib_get_image_blue_curve(id:PImlibData; image:PImlibImage; mods:Pbyte);cdecl;external imlibdll name 'Imlib_get_image_blue_curve';
  222. procedure Imlib_apply_modifiers_to_rgb(id:PImlibData; image:PImlibImage);cdecl;external imlibdll name 'Imlib_apply_modifiers_to_rgb';
  223. procedure Imlib_changed_image(id:PImlibData; image:PImlibImage);cdecl;external imlibdll name 'Imlib_changed_image';
  224. procedure Imlib_apply_image(id:PImlibData; image:PImlibImage; p:TWindow);cdecl;external imlibdll name 'Imlib_apply_image';
  225. procedure Imlib_paste_image(id:PImlibData; image:PImlibImage; p:TWindow; x:longint; y:longint;
  226. w:longint; h:longint);cdecl;external imlibdll name 'Imlib_paste_image';
  227. procedure Imlib_paste_image_border(id:PImlibData; image:PImlibImage; p:TWindow; x:longint; y:longint;
  228. w:longint; h:longint);cdecl;external imlibdll name 'Imlib_paste_image_border';
  229. procedure Imlib_bevel_image(id:PImlibData; image:PImlibImage; bord:PImlibBorder; up:byte);cdecl;external imlibdll name 'Imlib_bevel_image';
  230. procedure Imlib_bevel_pixmap(id:PImlibData; p:TPixmap; w:longint; h:longint; bord:PImlibBorder;
  231. up:byte);cdecl;external imlibdll name 'Imlib_bevel_pixmap';
  232. procedure Imlib_flip_image_horizontal(id:PImlibData; image:PImlibImage);cdecl;external imlibdll name 'Imlib_flip_image_horizontal';
  233. procedure Imlib_flip_image_vertical(id:PImlibData; image:PImlibImage);cdecl;external imlibdll name 'Imlib_flip_image_vertical';
  234. procedure Imlib_rotate_image(id:PImlibData; image:PImlibImage; d:longint);cdecl;external imlibdll name 'Imlib_rotate_image';
  235. function Imlib_create_image_from_data(id:PImlibData; data:Pbyte; alpha:Pbyte; w:longint; h:longint):PImlibimage;cdecl;external imlibdll name 'Imlib_create_image_from_data';
  236. function Imlib_clone_image(id:PImlibData; image:PImlibImage):PImlibImage;cdecl;external imlibdll name 'Imlib_clone_image';
  237. function Imlib_clone_scaled_image(id:PImlibData; image:PImlibImage; w:longint; h:longint):PImlibImage;cdecl;external imlibdll name 'Imlib_clone_scaled_image';
  238. function Imlib_get_fallback(id:PImlibData):longint;cdecl;external imlibdll name 'Imlib_get_fallback';
  239. procedure Imlib_set_fallback(id:PImlibData; fallback:longint);cdecl;external imlibdll name 'Imlib_set_fallback';
  240. function Imlib_get_visual(id:PImlibData):PVisual;cdecl;external imlibdll name 'Imlib_get_visual';
  241. function Imlib_get_colormap(id:PImlibData):TColormap;cdecl;external imlibdll name 'Imlib_get_colormap';
  242. function Imlib_get_sysconfig(id:PImlibData):PAnsiChar;cdecl;external imlibdll name 'Imlib_get_sysconfig';
  243. function Imlib_create_image_from_xpm_data(id:PImlibData; data:PPAnsiChar):PImlibImage;cdecl;external imlibdll name 'Imlib_create_image_from_xpm_data';
  244. function Imlib_data_to_pixmap(id:PImlibData; data:PPAnsiChar; pmap:PPixmap; mask:PPixmap):longint;cdecl;external imlibdll name 'Imlib_data_to_pixmap';
  245. procedure Imlib_crop_image(id:PImlibData; image:PImlibImage; x:longint; y:longint; w:longint;
  246. h:longint);cdecl;external imlibdll name 'Imlib_crop_image';
  247. function Imlib_save_image(id:PImlibData; image:PImlibImage; thefile:PAnsiChar; info:PImlibSaveInfo):longint;cdecl;external imlibdll name 'Imlib_save_image';
  248. function Imlib_crop_and_clone_image(id:PImlibData; image:PImlibImage; x:longint; y:longint; w:longint;
  249. h:longint):PImlibImage;cdecl;external imlibdll name 'Imlib_crop_and_clone_image';
  250. function Imlib_create_image_from_drawable(id:PImlibData; win:TDrawable; mask:TPixmap; x:longint; y:longint;
  251. width:longint; height:longint):PImlibImage;cdecl;external imlibdll name 'Imlib_create_image_from_drawable';
  252. function Imlib_inlined_png_to_image(id:PImlibData; data:Pbyte; data_size:longint):PImlibImage;cdecl;external imlibdll name 'Imlib_inlined_png_to_image';
  253. implementation
  254. end.