gdkpixbuf.pp 24 KB

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