gdkpixbuf.pp 23 KB

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