imlib.pp 14 KB

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