gdkpixbuf.pp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. {
  2. GdkPixbuf library
  3. Copyright (C) 1999 The Free Software Foundation
  4. Authors: Mark Crichton <[email protected]>
  5. Miguel de Icaza <[email protected]>
  6. Federico Mena-Quintero <[email protected]>
  7. Havoc Pennington <[email protected]>
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Library General Public License for more details.
  16. You should have received a copy of the GNU Library General Public
  17. License along with this library; if not, write to the
  18. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.
  20. **********************************************************************}
  21. unit gdkpixbuf;
  22. interface
  23. {$ifndef os2}
  24. {$Ifdef FPC}
  25. {$PACKRECORDS C}
  26. {$EndIf}
  27. {.$Define XLIB_SUPPORT} (* Use gdk_pixbuf_xlib instead of gdk_pixbuf *)
  28. {$Define GTK_SUPPORT} (* enable TGdkPixbufLoader support *)
  29. {.$Define GNOME_SUPPORT} (* enable TGnomeCanvasPixbuf support *)
  30. {$IFDef XLIB_SUPPORT}
  31. {$Ifdef FPC}
  32. {$linklib gdk_pixbuf_xlib}
  33. {$EndIf}
  34. {$Undef GTK_SUPPORT} (* Ensure GTK is disabled in XLIB mode *)
  35. {$Undef GNOME_SUPPORT} (* Ensure GNOME is disabled in XLIB mode *)
  36. {$Else}
  37. {$Ifdef FPC}
  38. {$linklib gdk_pixbuf}
  39. {$EndIf}
  40. {$IFDef GNOME_SUPPORT}
  41. {$Define GTK_SUPPORT} (* Ensure GTK is enabled if GNOME is *)
  42. {$EndIf}
  43. {$EndIf}
  44. Uses
  45. GLIB,
  46. {$IFDef XLIB_SUPPORT}
  47. XLib,
  48. {$Else}
  49. GDK
  50. {$IFDef GTK_SUPPORT}
  51. ,GTK
  52. {$IfDef GNOME_SUPPORT}
  53. ,GNOME
  54. {$ENDIF}
  55. {$ENDIF}
  56. {$ENDIF};
  57. {$IFDef XLIB_SUPPORT}
  58. const
  59. libgdkpixbuf =
  60. {$Ifdef FPC}
  61. 'gdk_pixbuf_xlib'; (* Set library to gdk_pixbuf_xlib *)
  62. {$Else}
  63. 'libgdk_pixbuf_xlib.so'; (* Set library to gdk_pixbuf_xlib *)
  64. {$EndIf}
  65. {$Else}
  66. const
  67. libgdkpixbuf =
  68. {$Ifdef FPC}
  69. 'gdk_pixbuf'; (* Set library to gdk_pixbuf *)
  70. {$Else}
  71. 'libgdk_pixbuf.so'; (* Set library to gdk_pixbuf *)
  72. {$EndIf}
  73. {$EndIf}
  74. {From gdk-pixbuf-features.h}
  75. const
  76. GDK_PIXBUF_FEATURES_H = 1;
  77. GDK_PIXBUF_MAJOR = 0;
  78. GDK_PIXBUF_MINOR = 16;
  79. GDK_PIXBUF_MICRO = 0;
  80. GDK_PIXBUF_VERSION_ = '0.16.0';
  81. {$Ifdef FPC}
  82. var
  83. {$ifndef darwin}
  84. gdk_pixbuf_major_version : guint; cvar; external;
  85. gdk_pixbuf_version : Pchar; cvar; external;
  86. {$else darwin}
  87. gdk_pixbuf_major_version : guint; external libgdkpixbuf name 'gdk_pixbuf_major_version';
  88. gdk_pixbuf_version : Pchar; external libgdkpixbuf name 'gdk_pixbuf_version';
  89. {$endif darwin}
  90. {$EndIf}
  91. {From gdk-pixbuf.h}
  92. type
  93. TGdkColorspace = (GDK_COLORSPACE_RGB);
  94. { All of these are opaque structures }
  95. _GdkPixbuf = Record
  96. end;
  97. TGdkPixbuf = _GdkPixbuf;
  98. PGdkPixbuf = ^TGdkPixbuf;
  99. _GdkPixbufFrame = Record
  100. end;
  101. TGdkPixbufFrame = _GdkPixbufFrame;
  102. PGdkPixbufFrame = ^TGdkPixbufFrame;
  103. _GdkPixbufAnimation = Record
  104. end;
  105. TGdkPixbufAnimation = _GdkPixbufAnimation;
  106. PGdkPixbufAnimation = ^TGdkPixbufAnimation;
  107. { Handler that must free the pixel array }
  108. TGdkPixbufDestroyNotify = Function (pixels : Pguchar; data : gpointer) : Pointer;
  109. { Handler for the last unref operation }
  110. TGdkPixbufLastUnref = Function (pixbuf : PGdkPixbuf; data : gpointer) : Pointer;
  111. { Reference counting }
  112. function gdk_pixbuf_ref(pixbuf:PGdkPixbuf):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_ref';
  113. procedure gdk_pixbuf_unref(pixbuf:PGdkPixbuf);cdecl; external libgdkpixbuf name 'gdk_pixbuf_unref';
  114. procedure gdk_pixbuf_set_last_unref_handler(pixbuf:PGdkPixbuf; last_unref_fn:TGdkPixbufLastUnref; last_unref_fn_data:gpointer);cdecl; external libgdkpixbuf name 'gdk_pixbuf_set_last_unref_handler';
  115. procedure gdk_pixbuf_finalize(pixbuf:PGdkPixbuf);cdecl; external libgdkpixbuf name 'gdk_pixbuf_finalize';
  116. { GdkPixbuf accessors }
  117. function gdk_pixbuf_get_colorspace(pixbuf:PGdkPixbuf):TGdkColorspace;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_colorspace';
  118. function gdk_pixbuf_get_n_channels(pixbuf:PGdkPixbuf):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_n_channels';
  119. function gdk_pixbuf_get_has_alpha(pixbuf:PGdkPixbuf):gboolean;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_has_alpha';
  120. function gdk_pixbuf_get_bits_per_sample(pixbuf:PGdkPixbuf):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_bits_per_sample';
  121. function gdk_pixbuf_get_pixels(pixbuf:PGdkPixbuf):Pguchar;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_pixels';
  122. function gdk_pixbuf_get_width(pixbuf:PGdkPixbuf):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_width';
  123. function gdk_pixbuf_get_height(pixbuf:PGdkPixbuf):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_height';
  124. function gdk_pixbuf_get_rowstride(pixbuf:PGdkPixbuf):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_rowstride';
  125. { Create a blank pixbuf with an optimal rowstride and a new buffer }
  126. function gdk_pixbuf_new(colorspace:TGdkColorspace; has_alpha:gboolean; bits_per_sample:longint; width:longint; height:longint):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_new';
  127. { Copy a pixbuf }
  128. function gdk_pixbuf_copy(pixbuf:PGdkPixbuf):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_copy';
  129. { Simple loading }
  130. function gdk_pixbuf_new_from_file(filename:Pchar):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_new_from_file';
  131. function gdk_pixbuf_new_from_data(data:Pguchar; colorspace:TGdkColorspace; has_alpha:gboolean; bits_per_sample:longint; width:longint;
  132. height:longint; rowstride:longint; destroy_fn:TGdkPixbufDestroyNotify; destroy_fn_data:gpointer):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_new_from_data';
  133. function gdk_pixbuf_new_from_xpm_data(data:PPchar):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_new_from_xpm_data';
  134. { Adding an alpha channel }
  135. function gdk_pixbuf_add_alpha(pixbuf:PGdkPixbuf; substitute_color:gboolean; r:guchar; g:guchar; b:guchar):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_add_alpha';
  136. { Copy an area of a pixbuf onto another one }
  137. procedure gdk_pixbuf_copy_area(src_pixbuf:PGdkPixbuf; src_x:longint; src_y:longint; width:longint; height:longint;
  138. dest_pixbuf:PGdkPixbuf; dest_x:longint; dest_y:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_copy_area';
  139. type
  140. TGdkPixbufAlphaMode = (GDK_PIXBUF_ALPHA_BILEVEL,GDK_PIXBUF_ALPHA_FULL);
  141. {$IfNDef XLIB_SUPPORT}
  142. { Rendering to a TGDKDrawable }
  143. procedure gdk_pixbuf_render_threshold_alpha(pixbuf:PGdkPixbuf; bitmap:PGdkBitmap; src_x:longint; src_y:longint; dest_x:longint;
  144. dest_y:longint; width:longint; height:longint; alpha_threshold:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_render_threshold_alpha';
  145. procedure gdk_pixbuf_render_to_drawable(pixbuf:PGdkPixbuf; Drawable:PGDKDrawable; GC:PGDKGC; src_x:longint; src_y:longint;
  146. dest_x:longint; dest_y:longint; width:longint; height:longint; dither:TGDKRGBDither;
  147. x_dither:longint; y_dither:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_render_to_drawable';
  148. procedure gdk_pixbuf_render_to_drawable_alpha(pixbuf:PGdkPixbuf; Drawable:PGDKDrawable; src_x:longint; src_y:longint; dest_x:longint;
  149. dest_y:longint; width:longint; height:longint; alpha_mode:TGdkPixbufAlphaMode; alpha_threshold:longint;
  150. dither:TGDKRGBDither; x_dither:longint; y_dither:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_render_to_drawable_alpha';
  151. procedure gdk_pixbuf_render_pixmap_and_mask(pixbuf:PGdkPixbuf; Pixmap_return:PPGDKPixmap; mask_return:PPGdkBitmap; alpha_threshold:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_render_pixmap_and_mask';
  152. { Fetching a region from a TDrawable }
  153. function gdk_pixbuf_get_from_drawable(dest:PGdkPixbuf; src:PGDKDrawable; cmap:PGDKColormap; src_x:longint; src_y:longint;
  154. dest_x:longint; dest_y:longint; width:longint; height:longint):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_get_from_drawable';
  155. {$EndIf}
  156. { Scaling }
  157. type
  158. TGdkInterpType = (GDK_INTERP_NEAREST,GDK_INTERP_TILES,
  159. GDK_INTERP_BILINEAR,GDK_INTERP_HYPER);
  160. procedure gdk_pixbuf_scale(src:PGdkPixbuf; dest:PGdkPixbuf; dest_x:longint; dest_y:longint; dest_width:longint;
  161. dest_height:longint; offset_x:double; offset_y:double; scale_x:double; scale_y:double;
  162. interp_type:TGdkInterpType);cdecl; external libgdkpixbuf name 'gdk_pixbuf_scale';
  163. procedure gdk_pixbuf_composite(src:PGdkPixbuf; dest:PGdkPixbuf; dest_x:longint; dest_y:longint; dest_width:longint;
  164. dest_height:longint; offset_x:double; offset_y:double; scale_x:double; scale_y:double;
  165. interp_type:TGdkInterpType; overall_alpha:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_composite';
  166. procedure gdk_pixbuf_composite_color(src:PGdkPixbuf; dest:PGdkPixbuf; dest_x:longint; dest_y:longint; dest_width:longint;
  167. dest_height:longint; offset_x:double; offset_y:double; scale_x:double; scale_y:double;
  168. interp_type:TGdkInterpType; overall_alpha:longint; check_x:longint; check_y:longint; check_size:longint;
  169. color1:guint32; color2:guint32);cdecl; external libgdkpixbuf name 'gdk_pixbuf_composite_color';
  170. function gdk_pixbuf_scale_simple(src:PGdkPixbuf; dest_width:longint; dest_height:longint; interp_type:TGdkInterpType):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_scale_simple';
  171. function gdk_pixbuf_composite_color_simple(src:PGdkPixbuf; dest_width:longint; dest_height:longint; interp_type:TGdkInterpType; overall_alpha:longint;
  172. check_size:longint; color1:guint32; color2:guint32):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_composite_color_simple';
  173. { Animation support }
  174. { GIF-like animation overlay modes for frames }
  175. type
  176. TGdkPixbufFrameAction = (GDK_PIXBUF_FRAME_RETAIN,GDK_PIXBUF_FRAME_DISPOSE,
  177. GDK_PIXBUF_FRAME_REVERT);
  178. function gdk_pixbuf_animation_new_from_file(filename:Pchar):PGdkPixbufAnimation;cdecl; external libgdkpixbuf name 'gdk_pixbuf_animation_new_from_file';
  179. function gdk_pixbuf_animation_ref(animation:PGdkPixbufAnimation):PGdkPixbufAnimation;cdecl; external libgdkpixbuf name 'gdk_pixbuf_animation_ref';
  180. procedure gdk_pixbuf_animation_unref(animation:PGdkPixbufAnimation);cdecl; external libgdkpixbuf name 'gdk_pixbuf_animation_unref';
  181. function gdk_pixbuf_animation_get_width(animation:PGdkPixbufAnimation):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_animation_get_width';
  182. function gdk_pixbuf_animation_get_height(animation:PGdkPixbufAnimation):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_animation_get_height';
  183. function gdk_pixbuf_animation_get_frames(animation:PGdkPixbufAnimation):PGList;cdecl; external libgdkpixbuf name 'gdk_pixbuf_animation_get_frames';
  184. function gdk_pixbuf_animation_get_num_frames(animation:PGdkPixbufAnimation):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_animation_get_num_frames';
  185. { Frame accessors }
  186. function gdk_pixbuf_frame_get_pixbuf(frame:PGdkPixbufFrame):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_frame_get_pixbuf';
  187. function gdk_pixbuf_frame_get_x_offset(frame:PGdkPixbufFrame):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_frame_get_x_offset';
  188. function gdk_pixbuf_frame_get_y_offset(frame:PGdkPixbufFrame):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_frame_get_y_offset';
  189. function gdk_pixbuf_frame_get_delay_time(frame:PGdkPixbufFrame):longint;cdecl; external libgdkpixbuf name 'gdk_pixbuf_frame_get_delay_time';
  190. function gdk_pixbuf_frame_get_action(frame:PGdkPixbufFrame):TGdkPixbufFrameAction;cdecl; external libgdkpixbuf name 'gdk_pixbuf_frame_get_action';
  191. { General (presently empty) initialization hooks, primarily for gnome-libs }
  192. procedure gdk_pixbuf_preinit(app:gpointer; modinfo:gpointer);cdecl; external libgdkpixbuf name 'gdk_pixbuf_preinit';
  193. procedure gdk_pixbuf_postinit(app:gpointer; modinfo:gpointer);cdecl; external libgdkpixbuf name 'gdk_pixbuf_postinit';
  194. {From gdk-pixbuf-loader.h}
  195. {$IfDef GTK_SUPPORT}
  196. Type
  197. _GdkPixbufLoaderPrivate = record
  198. end;
  199. TGdkPixbufLoaderPrivate = _GdkPixbufLoaderPrivate;
  200. PGdkPixbufLoaderPrivate = ^TGdkPixbufLoaderPrivate;
  201. _GdkPixbufLoader = record
  202. theobject : PGtkObject;
  203. { Private data }
  204. priv : PGdkPixbufLoaderPrivate;
  205. end;
  206. TGdkPixbufLoader = _GdkPixbufLoader;
  207. PGdkPixbufLoader = ^TGdkPixbufLoader;
  208. _GdkPixbufLoaderClass = record
  209. parent_class : PGtkObjectClass;
  210. area_prepared : Function (loader : PGdkPixbufLoader) : Pointer; cdecl;
  211. area_updated : Function (loader : PGdkPixbufLoader; x, y, width, height : guint) : Pointer; cdecl;
  212. frame_done : Function (loader : PGdkPixbufLoader; frame : PGdkPixbufFrame) : Pointer; cdecl;
  213. animation_done : Function (loader : PGdkPixbufLoader) : Pointer; cdecl;
  214. closed : Function (loader : PGdkPixbufLoader) : Pointer; cdecl;
  215. end;
  216. TGdkPixbufLoaderClass = _GdkPixbufLoaderClass;
  217. PGdkPixbufLoaderClass = ^TGdkPixbufLoaderClass;
  218. type
  219. GDK_PIXBUF_LOADER=PGDKPIXBUFLOADER;
  220. GDK_PIXBUF_LOADER_CLASS=PGDKPIXBUFLOADERClass;
  221. Function gdk_pixbuf_loader_get_type : TGtkType; cdecl; external libgdkpixbuf name 'gdk_pixbuf_loader_get_type';
  222. Function gdk_pixbuf_loader_new : PGdkPixbufLoader; cdecl; external libgdkpixbuf name 'gdk_pixbuf_loader_new';
  223. Function gdk_pixbuf_loader_write(loader : PGdkPixbufLoader;
  224. const buf : Pguchar; count : longint) : gBoolean; cdecl; external libgdkpixbuf name 'gdk_pixbuf_loader_write';
  225. Function gdk_pixbuf_loader_get_pixbuf(loader : PGdkPixbufLoader) : PGdkPixbuf; cdecl; external libgdkpixbuf name 'gdk_pixbuf_loader_get_pixbuf';
  226. Function gdk_pixbuf_loader_get_animation (loader : PGdkPixbufLoader) : PGdkPixbufAnimation; cdecl; external libgdkpixbuf name 'gdk_pixbuf_loader_get_animation';
  227. Procedure gdk_pixbuf_loader_close(loader : PGdkPixbufLoader); cdecl; external libgdkpixbuf name 'gdk_pixbuf_loader_close';
  228. Function GDK_TYPE_PIXBUF_LOADER : TGtkType;
  229. Function GDK_IS_PIXBUF_LOADER(obj:pointer) : boolean;
  230. Function GDK_IS_PIXBUF_LOADER_CLASS(klass:pointer) : boolean;
  231. {$EndIf}
  232. {From gdk-pixbuf-xlibrgb.h}
  233. {$IfDef XLIB_SUPPORT}
  234. type
  235. _XlibRgbCmap = record
  236. colors : array[0..255] of dword;
  237. lut : array[0..255] of byte;
  238. end;
  239. TXlibRgbCmap = _XlibRgbCmap;
  240. PXlibRgbCmap = ^TXlibRgbCmap;
  241. procedure xlib_rgb_init(display:PDisplay; screen:PScreen);cdecl; external libgdkpixbuf name 'xlib_rgb_init';
  242. procedure xlib_rgb_init_with_depth(display:PDisplay; screen:PScreen; prefDepth:longint);cdecl; external libgdkpixbuf name 'xlib_rgb_init_with_depth';
  243. function xlib_rgb_xpixel_from_rgb(rgb:guint32):dword;cdecl; external libgdkpixbuf name 'xlib_rgb_xpixel_from_rgb';
  244. procedure xlib_rgb_gc_set_foreground(GC:TGC; rgb:guint32);cdecl; external libgdkpixbuf name 'xlib_rgb_gc_set_foreground';
  245. procedure xlib_rgb_gc_set_background(GC:TGC; rgb:guint32);cdecl; external libgdkpixbuf name 'xlib_rgb_gc_set_background';
  246. type
  247. TXlibRgbDither = (XLIB_RGB_DITHER_NONE,XLIB_RGB_DITHER_NORMAL,
  248. XLIB_RGB_DITHER_MAX);
  249. procedure xlib_draw_rgb_image(Drawable:TDrawable; GC:TGC; x:longint; y:longint; width:longint;
  250. height:longint; dith:TXlibRgbDither; rgb_buf:Pbyte; rowstride:longint);cdecl; external libgdkpixbuf name 'xlib_draw_rgb_image';
  251. procedure xlib_draw_rgb_image_dithalign(Drawable:TDrawable; GC:TGC; x:longint; y:longint; width:longint;
  252. height:longint; dith:TXlibRgbDither; rgb_buf:Pbyte; rowstride:longint; xdith:longint;
  253. ydith:longint);cdecl; external libgdkpixbuf name 'xlib_draw_rgb_image_dithalign';
  254. procedure xlib_draw_rgb_32_image(Drawable:TDrawable; GC:TGC; x:longint; y:longint; width:longint;
  255. height:longint; dith:TXlibRgbDither; buf:Pbyte; rowstride:longint);cdecl; external libgdkpixbuf name 'xlib_draw_rgb_32_image';
  256. procedure xlib_draw_gray_image(Drawable:TDrawable; GC:TGC; x:longint; y:longint; width:longint;
  257. height:longint; dith:TXlibRgbDither; buf:Pbyte; rowstride:longint);cdecl; external libgdkpixbuf name 'xlib_draw_gray_image';
  258. function xlib_rgb_cmap_new(colors:Pguint32; n_colors:longint):PXlibRgbCmap;cdecl; external libgdkpixbuf name 'xlib_rgb_cmap_new';
  259. procedure xlib_rgb_cmap_free(cmap:PXlibRgbCmap);cdecl; external libgdkpixbuf name 'xlib_rgb_cmap_free';
  260. procedure xlib_draw_indexed_image(Drawable:TDrawable; GC:TGC; x:longint; y:longint; width:longint;
  261. height:longint; dith:TXlibRgbDither; buf:Pbyte; rowstride:longint; cmap:PXlibRgbCmap);cdecl; external libgdkpixbuf name 'xlib_draw_indexed_image';
  262. { Below are some functions which are primarily useful for debugging
  263. and experimentation. }
  264. function xlib_rgb_ditherable:LongBool;cdecl; external libgdkpixbuf name 'xlib_rgb_ditherable';
  265. procedure xlib_rgb_set_verbose(verbose:LongBool);cdecl; external libgdkpixbuf name 'xlib_rgb_set_verbose';
  266. { experimental TColormap stuff }
  267. procedure xlib_rgb_set_install(install:LongBool);cdecl; external libgdkpixbuf name 'xlib_rgb_set_install';
  268. procedure xlib_rgb_set_min_colors(min_colors:longint);cdecl; external libgdkpixbuf name 'xlib_rgb_set_min_colors';
  269. function xlib_rgb_get_cmap:TColormap;cdecl; external libgdkpixbuf name 'xlib_rgb_get_cmap';
  270. function xlib_rgb_get_visual:PVisual;cdecl; external libgdkpixbuf name 'xlib_rgb_get_visual';
  271. function xlib_rgb_get_visual_info:PXVisualInfo;cdecl; external libgdkpixbuf name 'xlib_rgb_get_visual_info';
  272. function xlib_rgb_get_depth:longint;cdecl; external libgdkpixbuf name 'xlib_rgb_get_depth';
  273. function xlib_rgb_get_display:PDisplay;cdecl; external libgdkpixbuf name 'xlib_rgb_get_display';
  274. function xlib_rgb_get_screen:PScreen;cdecl; external libgdkpixbuf name 'xlib_rgb_get_screen';
  275. {$EndIf}
  276. {From gdk-pixbuf-xlib.h}
  277. {$IfDef XLIB_SUPPORT}
  278. procedure gdk_pixbuf_xlib_init(display:PDisplay; screen_num:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_xlib_init';
  279. procedure gdk_pixbuf_xlib_init_with_depth(display:PDisplay; screen_num:longint; prefDepth:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_xlib_init_with_depth';
  280. procedure gdk_pixbuf_xlib_render_threshold_alpha(pixbuf:PGdkPixbuf; bitmap:TPixmap; src_x:longint; src_y:longint; dest_x:longint;
  281. dest_y:longint; width:longint; height:longint; alpha_threshold:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_xlib_render_threshold_alpha';
  282. procedure gdk_pixbuf_xlib_render_to_drawable(pixbuf:PGdkPixbuf; Drawable:TDrawable; GC:TGC; src_x:longint; src_y:longint;
  283. dest_x:longint; dest_y:longint; width:longint; height:longint; dither:TXlibRgbDither;
  284. x_dither:longint; y_dither:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_xlib_render_to_drawable';
  285. procedure gdk_pixbuf_xlib_render_to_drawable_alpha(pixbuf:PGdkPixbuf; Drawable:TDrawable; src_x:longint; src_y:longint; dest_x:longint;
  286. dest_y:longint; width:longint; height:longint; alpha_mode:TGdkPixbufAlphaMode; alpha_threshold:longint;
  287. dither:TXlibRgbDither; x_dither:longint; y_dither:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_xlib_render_to_drawable_alpha';
  288. procedure gdk_pixbuf_xlib_render_Pixmap_and_mask(pixbuf:PGdkPixbuf; Pixmap_return:PPixmap; mask_return:PPixmap; alpha_threshold:longint);cdecl; external libgdkpixbuf name 'gdk_pixbuf_xlib_render_Pixmap_and_mask';
  289. function gdk_pixbuf_xlib_get_from_drawable(dest:PGdkPixbuf; src:TDrawable; cmap:TColormap; visual:PVisual; src_x:longint;
  290. src_y:longint; dest_x:longint; dest_y:longint; width:longint; height:longint):PGdkPixbuf;cdecl; external libgdkpixbuf name 'gdk_pixbuf_xlib_get_from_drawable';
  291. {$EndIf}
  292. {From gnome-canvas-pixbuf.h}
  293. {$IfDef GNOME_SUPPORT}
  294. Type
  295. _GnomeCanvasPixbuf = record
  296. item : TGnomeCanvasItem;
  297. { Private data }
  298. priv :gpointer;
  299. end;
  300. TGnomeCanvasPixbuf = _GnomeCanvasPixbuf;
  301. PGnomeCanvasPixbuf = ^TGnomeCanvasPixbuf;
  302. _GnomeCanvasPixbufClass = record
  303. parent_class : TGnomeCanvasItemClass;
  304. end;
  305. TGnomeCanvasPixbufClass = _GnomeCanvasPixbufClass;
  306. PGnomeCanvasPixbufClass = ^TGnomeCanvasPixbufClass;
  307. GNOME_CANVAS_PIXBUF = PGNOMECANVASPIXBUF;
  308. GNOME_CANVAS_PIXBUF_CLASS = PGnomeCanvasPixbufClass
  309. Function GNOME_TYPE_CANVAS_PIXBUF : TGTKType; cdcel; external libgdkpixbuf name 'gnome_canvas_pixbuf_get_type';
  310. Function GNOME_IS_CANVAS_PIXBUF(obj : Pointer);
  311. Function GNOME_IS_CANVAS_PIXBUF_CLASS(klass : Pointer);
  312. Function gnome_canvas_pixbuf_get_type : PGtkType; cdecl; external libgdkpixbuf name 'gnome_canvas_pixbuf_get_type';
  313. {$EndIf}
  314. {$endif os2}
  315. implementation
  316. {$ifndef os2}
  317. {$Ifdef FPC}
  318. { There is a bug in the compiler. If an external variable is not used, it will
  319. create code, that can not be relocated by the linker.
  320. So, use them in this hidden procedure.
  321. }
  322. procedure CheckUnusedVariable; [Public];
  323. begin
  324. if (gdk_pixbuf_major_version=0)
  325. or (gdk_pixbuf_version=nil) then ;
  326. end;
  327. {$EndIf}
  328. {$IfDef GTK_SUPPORT}
  329. Function GDK_TYPE_PIXBUF_LOADER : TGtkType;
  330. begin
  331. GDK_TYPE_PIXBUF_LOADER := gdk_pixbuf_loader_get_type;
  332. end;
  333. Function GDK_IS_PIXBUF_LOADER(obj : pointer) : boolean;
  334. begin
  335. GDK_IS_PIXBUF_LOADER :=(obj<>nil) and GDK_IS_PIXBUF_LOADER_CLASS(PGtkTypeObject(obj)^.klass);
  336. end;
  337. Function GDK_IS_PIXBUF_LOADER_CLASS(klass:pointer) : boolean;
  338. begin
  339. GDK_IS_PIXBUF_LOADER_CLASS:=(klass<>nil) and (PGtkTypeClass(klass)^.thetype=GDK_TYPE_PIXBUF_LOADER);
  340. end;
  341. {$EndIf}
  342. {$IfDef GNOME_SUPPORT}
  343. Function GNOME_IS_CANVAS_PIXBUF(obj : Pointer);
  344. begin
  345. GNOME_IS_CANVAS_PIXBUF :=(obj<>nil) and GNOME_IS_CANVAS_PIXBUF_CLASS(PGtkTypeObject(obj)^.klass);
  346. end;
  347. Function GNOME_IS_CANVAS_PIXBUF_CLASS(klass : Pointer);
  348. begin
  349. GNOME_IS_CANVAS_PIXBUF_CLASS:=(klass<>nil) and (PGtkTypeClass(klass)^.thetype=GNOME_TYPE_CANVAS_PIXBUF);
  350. end;
  351. {$EndIf}
  352. {$endif os2}
  353. end.