gdk2pixbuf.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. { GdkPixbuf library - Main header file
  2. Copyright (C) 1999 The Free Software Foundation
  3. Authors: Mark Crichton <[email protected]>
  4. Miguel de Icaza <[email protected]>
  5. Federico Mena-Quintero <[email protected]>
  6. Havoc Pennington <[email protected]>
  7. This library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public
  9. License as published by the Free Software Foundation; either
  10. version 2 of the License, or (at your option) any later version.
  11. This library is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with this library; if not, write to the
  17. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. Boston, MA 02111-1307, USA.
  19. }
  20. unit gdk2pixbuf; // keep unit name lowercase for kylix
  21. {$IFDEF FPC}
  22. {$mode objfpc}
  23. {$ENDIF}
  24. {$IFDEF VER140}
  25. {$DEFINE KYLIX}
  26. {$ENDIF}
  27. interface
  28. uses glib2;
  29. const
  30. {$ifdef win32}
  31. {$define gdkpixbufwin}
  32. gdkpixbuflib = 'libgdk_pixbuf-2.0-0.dll';
  33. {$IFDEF FPC}
  34. {$smartlink on}
  35. {$ENDIF}
  36. {$else}
  37. {$ifdef darwin}
  38. gdkpixbuflib = 'gdk_pixbuf-2.0.0';
  39. {$linklib gtk-x11-2.0}
  40. {$linklib gdk-x11-2.0}
  41. {$linklib pango-1.0.0}
  42. {$linklib glib-2.0.0}
  43. {$linklib gobject-2.0.0}
  44. {$linklib gdk_pixbuf-2.0.0}
  45. {$linklib atk-1.0.0}
  46. {$else}
  47. {$ifdef UseCustomLibs}
  48. gdkpixbuflib = '';
  49. {$else}
  50. gdkpixbuflib = 'libgdk_pixbuf-2.0.so';
  51. {$endif}
  52. {$endif}
  53. {$endif}
  54. { Pointers to basic pascal types, inserted by h2pas conversion program.}
  55. {$IFNDEF KYLIX}
  56. {$PACKRECORDS C}
  57. {$ELSE}
  58. {$ALIGN 4}
  59. {$WEAKPACKAGEUNIT}
  60. {$WARNINGS OFF}
  61. {$ENDIF}
  62. {$IFNDEF Kylix}
  63. var
  64. gdk_pixbuf_major_version: guint;cvar;external;
  65. gdk_pixbuf_minor_version: guint;cvar;external;
  66. gdk_pixbuf_micro_version: guint;cvar;external;
  67. gdk_pixbuf_version: PChar;cvar;external;
  68. {$ENDIF}
  69. type
  70. // internal type
  71. PGdkPixbuf = pointer;
  72. // internal type
  73. PGdkPixbufAnimation = pointer;
  74. // internal type
  75. PGdkPixbufAnimationIter = pointer;
  76. { Alpha compositing mode }
  77. PGdkPixbufAlphaMode = ^TGdkPixbufAlphaMode;
  78. TGdkPixbufAlphaMode = (
  79. GDK_PIXBUF_ALPHA_BILEVEL,
  80. GDK_PIXBUF_ALPHA_FULL
  81. );
  82. { Color spaces; right now only RGB is supported.
  83. Note that these values are encoded in inline pixbufs
  84. as ints, so don't reorder them
  85. }
  86. PGdkColorspace = ^TGdkColorspace;
  87. TGdkColorspace = (GDK_COLORSPACE_RGB);
  88. { Handler that must free the pixel array }
  89. TGdkPixbufDestroyNotify = procedure (pixels:Pguchar; data:gpointer); cdecl;
  90. { image data hosed }
  91. { no mem to load image }
  92. { bad option passed to save routine }
  93. { unsupported image type (sort of an ENOSYS) }
  94. { unsupported operation (load, save) for image type }
  95. PGdkPixbufError = ^TGdkPixbufError;
  96. TGdkPixbufError = (
  97. GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
  98. GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
  99. GDK_PIXBUF_ERROR_BAD_OPTION,
  100. GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
  101. GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
  102. GDK_PIXBUF_ERROR_FAILED
  103. );
  104. { Interpolation modes }
  105. PGdkInterpType = ^TGdkInterpType;
  106. TGdkInterpType = (
  107. GDK_INTERP_NEAREST,
  108. GDK_INTERP_TILES,
  109. GDK_INTERP_BILINEAR,
  110. GDK_INTERP_HYPER
  111. );
  112. function GDK_TYPE_PIXBUF : GType;
  113. function GDK_PIXBUF(anObject : pointer) : PGdkPixbuf;
  114. function GDK_IS_PIXBUF(anObject : pointer) : boolean;
  115. function GDK_TYPE_PIXBUF_ANIMATION : GType;
  116. function GDK_PIXBUF_ANIMATION(anObject : pointer) : PGdkPixbufAnimation;
  117. function GDK_IS_PIXBUF_ANIMATION(anObject : pointer) : boolean;
  118. function GDK_TYPE_PIXBUF_ANIMATION_ITER : GType;
  119. function GDK_PIXBUF_ANIMATION_ITER(anObject : pointer) : PGdkPixbufAnimationIter;
  120. function GDK_IS_PIXBUF_ANIMATION_ITER(anObject : pointer) : boolean;
  121. function GDK_PIXBUF_ERROR : TGQuark;
  122. function gdk_pixbuf_error_quark:TGQuark; cdecl; external gdkpixbuflib;
  123. function gdk_pixbuf_get_type:GType; cdecl; external gdkpixbuflib;
  124. { Reference counting }
  125. {$ifndef GDK_PIXBUF_DISABLE_DEPRECATED}
  126. function gdk_pixbuf_ref(pixbuf:PGdkPixbuf):PGdkPixbuf; cdecl; external gdkpixbuflib;
  127. procedure gdk_pixbuf_unref(pixbuf:PGdkPixbuf); cdecl; external gdkpixbuflib;
  128. {$endif}
  129. { GdkPixbuf accessors }
  130. function gdk_pixbuf_get_colorspace(pixbuf:PGdkPixbuf):TGdkColorspace; cdecl; external gdkpixbuflib;
  131. function gdk_pixbuf_get_n_channels(pixbuf:PGdkPixbuf):longint; cdecl; external gdkpixbuflib;
  132. function gdk_pixbuf_get_has_alpha(pixbuf:PGdkPixbuf):gboolean; cdecl; external gdkpixbuflib;
  133. function gdk_pixbuf_get_bits_per_sample(pixbuf:PGdkPixbuf):longint; cdecl; external gdkpixbuflib;
  134. function gdk_pixbuf_get_pixels(pixbuf:PGdkPixbuf):Pguchar; cdecl; external gdkpixbuflib;
  135. function gdk_pixbuf_get_width(pixbuf:PGdkPixbuf):longint; cdecl; external gdkpixbuflib;
  136. function gdk_pixbuf_get_height(pixbuf:PGdkPixbuf):longint; cdecl; external gdkpixbuflib;
  137. function gdk_pixbuf_get_rowstride(pixbuf:PGdkPixbuf):longint; cdecl; external gdkpixbuflib;
  138. { Create a blank pixbuf with an optimal rowstride and a new buffer }
  139. function gdk_pixbuf_new(colorspace:TGdkColorspace; has_alpha:gboolean; bits_per_sample:longint; width:longint; height:longint):PGdkPixbuf; cdecl; external gdkpixbuflib;
  140. { Copy a pixbuf }
  141. function gdk_pixbuf_copy(pixbuf:PGdkPixbuf):PGdkPixbuf; cdecl; external gdkpixbuflib;
  142. { Create a pixbuf which points to the pixels of another pixbuf }
  143. function gdk_pixbuf_new_subpixbuf(src_pixbuf:PGdkPixbuf; src_x:longint; src_y:longint; width:longint; height:longint):PGdkPixbuf; cdecl; external gdkpixbuflib;
  144. { Simple loading }
  145. function gdk_pixbuf_new_from_file(filename:Pchar; error:PPGError):PGdkPixbuf; cdecl; external gdkpixbuflib;
  146. function gdk_pixbuf_new_from_data(data:Pguchar; colorspace:TGdkColorspace; has_alpha:gboolean; bits_per_sample:longint; width:longint;
  147. height:longint; rowstride:longint; destroy_fn:TGdkPixbufDestroyNotify; destroy_fn_data:gpointer):PGdkPixbuf; cdecl; external gdkpixbuflib;
  148. function gdk_pixbuf_new_from_xpm_data(data:PPchar):PGdkPixbuf; cdecl; external gdkpixbuflib;
  149. function gdk_pixbuf_new_from_inline(data_length:gint; var data:guint8; copy_pixels:gboolean; error:PPGError):PGdkPixbuf; cdecl; external gdkpixbuflib;
  150. { Mutations }
  151. procedure gdk_pixbuf_fill(pixbuf:PGdkPixbuf; pixel:guint32); cdecl; external gdkpixbuflib;
  152. { Saving }
  153. {$IFNDEF KYLIX}
  154. function gdk_pixbuf_save(pixbuf:PGdkPixbuf; filename:Pchar; _type:Pchar; error:PPGError; args:array of const):gboolean; cdecl; overload; external gdkpixbuflib;
  155. function gdk_pixbuf_save(pixbuf:PGdkPixbuf; filename:Pchar; _type:Pchar; error:PPGError):gboolean; cdecl; overload; external gdkpixbuflib;
  156. {$ELSE}
  157. function gdk_pixbuf_save(pixbuf:PGdkPixbuf; filename:Pchar; _type:Pchar; error:PPGError):gboolean; varargs; cdecl; external gdkpixbuflib;
  158. {$ENDIF}
  159. function gdk_pixbuf_savev(pixbuf:PGdkPixbuf; filename:Pchar; _type:Pchar; option_keys:PPchar; option_values:PPchar;
  160. error:PPGError):gboolean; cdecl; external gdkpixbuflib;
  161. { Adding an alpha channel }
  162. function gdk_pixbuf_add_alpha(pixbuf:PGdkPixbuf; substitute_color:gboolean; r:guchar; g:guchar; b:guchar):PGdkPixbuf; cdecl; external gdkpixbuflib;
  163. { Copy an area of a pixbuf onto another one }
  164. procedure gdk_pixbuf_copy_area(src_pixbuf:PGdkPixbuf; src_x:longint; src_y:longint; width:longint; height:longint;
  165. dest_pixbuf:PGdkPixbuf; dest_x:longint; dest_y:longint); cdecl; external gdkpixbuflib;
  166. { Brighten/darken and optionally make it pixelated-looking }
  167. procedure gdk_pixbuf_saturate_and_pixelate(src:PGdkPixbuf; dest:PGdkPixbuf; saturation:gfloat; pixelate:gboolean); cdecl; external gdkpixbuflib;
  168. { Rendering to a drawable }
  169. { Scaling }
  170. procedure gdk_pixbuf_scale(src:PGdkPixbuf; dest:PGdkPixbuf; dest_x:longint; dest_y:longint; dest_width:longint;
  171. dest_height:longint; offset_x:double; offset_y:double; scale_x:double; scale_y:double;
  172. interp_type:TGdkInterpType); cdecl; external gdkpixbuflib;
  173. procedure gdk_pixbuf_composite(src:PGdkPixbuf; dest:PGdkPixbuf; dest_x:longint; dest_y:longint; dest_width:longint;
  174. dest_height:longint; offset_x:double; offset_y:double; scale_x:double; scale_y:double;
  175. interp_type:TGdkInterpType; overall_alpha:longint); cdecl; external gdkpixbuflib;
  176. procedure gdk_pixbuf_composite_color(src:PGdkPixbuf; dest:PGdkPixbuf; dest_x:longint; dest_y:longint; dest_width:longint;
  177. dest_height:longint; offset_x:double; offset_y:double; scale_x:double; scale_y:double;
  178. interp_type:TGdkInterpType; overall_alpha:longint; check_x:longint; check_y:longint; check_size:longint;
  179. color1:guint32; color2:guint32); cdecl; external gdkpixbuflib;
  180. function gdk_pixbuf_scale_simple(src:PGdkPixbuf; dest_width:longint; dest_height:longint; interp_type:TGdkInterpType):PGdkPixbuf; cdecl; external gdkpixbuflib;
  181. function gdk_pixbuf_composite_color_simple(src:PGdkPixbuf; dest_width:longint; dest_height:longint; interp_type:TGdkInterpType; overall_alpha:longint;
  182. check_size:longint; color1:guint32; color2:guint32):PGdkPixbuf; cdecl; external gdkpixbuflib;
  183. { Animation support }
  184. function gdk_pixbuf_animation_get_type:GType; cdecl; external gdkpixbuflib;
  185. function gdk_pixbuf_animation_new_from_file(filename:Pchar; error:PPGError):PGdkPixbufAnimation; cdecl; external gdkpixbuflib;
  186. {$ifndef GDK_PIXBUF_DISABLE_DEPRECATED}
  187. function gdk_pixbuf_animation_ref(animation:PGdkPixbufAnimation):PGdkPixbufAnimation; cdecl; external gdkpixbuflib;
  188. procedure gdk_pixbuf_animation_unref(animation:PGdkPixbufAnimation); cdecl; external gdkpixbuflib;
  189. {$endif}
  190. function gdk_pixbuf_animation_get_width(animation:PGdkPixbufAnimation):longint; cdecl; external gdkpixbuflib;
  191. function gdk_pixbuf_animation_get_height(animation:PGdkPixbufAnimation):longint; cdecl; external gdkpixbuflib;
  192. function gdk_pixbuf_animation_is_static_image(animation:PGdkPixbufAnimation):gboolean; cdecl; external gdkpixbuflib;
  193. function gdk_pixbuf_animation_get_static_image(animation:PGdkPixbufAnimation):PGdkPixbuf; cdecl; external gdkpixbuflib;
  194. function gdk_pixbuf_animation_get_iter(animation:PGdkPixbufAnimation; var start_time:TGTimeVal):PGdkPixbufAnimationIter; cdecl; external gdkpixbuflib;
  195. function gdk_pixbuf_animation_iter_get_type:GType; cdecl; external gdkpixbuflib;
  196. function gdk_pixbuf_animation_iter_get_delay_time(iter:PGdkPixbufAnimationIter):longint; cdecl; external gdkpixbuflib;
  197. function gdk_pixbuf_animation_iter_get_pixbuf(iter:PGdkPixbufAnimationIter):PGdkPixbuf; cdecl; external gdkpixbuflib;
  198. function gdk_pixbuf_animation_iter_on_currently_loading_frame(iter:PGdkPixbufAnimationIter):gboolean; cdecl; external gdkpixbuflib;
  199. function gdk_pixbuf_animation_iter_advance(iter:PGdkPixbufAnimationIter; var current_time:TGTimeVal):gboolean; cdecl; external gdkpixbuflib;
  200. function gdk_pixbuf_get_option(pixbuf:PGdkPixbuf; key:Pgchar):Pgchar; cdecl; external gdkpixbuflib;
  201. {$DEFINE read_interface}
  202. {$include gdk-pixbuf-loader.inc}
  203. { $include gdk-pixbuf-enum-types.inc}
  204. {$UNDEF read_interface}
  205. implementation
  206. {$DEFINE read_implementation}
  207. {$include gdk-pixbuf-loader.inc}
  208. { $include gdk-pixbuf-enum-types.inc}
  209. {$UNDEF read_implementation}
  210. {$IFNDEF KYLIX}
  211. { There is a bug in the compiler. If an external variable is not used, it will
  212. create code, that can be relocated by the linker.
  213. So, use them in this hidden procedure.
  214. }
  215. procedure CheckUnusedVariable; [Public];
  216. begin
  217. if (gdk_pixbuf_major_version=0)
  218. and (gdk_pixbuf_minor_version=0)
  219. and (gdk_pixbuf_micro_version=0)
  220. and (gdk_pixbuf_version=nil) then ;
  221. end;
  222. {$ENDIF}
  223. function GDK_TYPE_PIXBUF : GType;
  224. begin
  225. GDK_TYPE_PIXBUF:=gdk_pixbuf_get_type;
  226. end;
  227. function GDK_PIXBUF(anObject : pointer) : PGdkPixbuf;
  228. begin
  229. GDK_PIXBUF:=PGdkPixbuf(G_TYPE_CHECK_INSTANCE_CAST(anObject,GDK_TYPE_PIXBUF));
  230. end;
  231. function GDK_IS_PIXBUF(anObject : pointer) : boolean;
  232. begin
  233. GDK_IS_PIXBUF:=G_TYPE_CHECK_INSTANCE_TYPE(anObject,GDK_TYPE_PIXBUF);
  234. end;
  235. function GDK_TYPE_PIXBUF_ANIMATION : GType;
  236. begin
  237. GDK_TYPE_PIXBUF_ANIMATION:=gdk_pixbuf_animation_get_type;
  238. end;
  239. function GDK_PIXBUF_ANIMATION(anObject : pointer) : PGdkPixbufAnimation;
  240. begin
  241. GDK_PIXBUF_ANIMATION:=PGdkPixbufAnimation(G_TYPE_CHECK_INSTANCE_CAST(anObject,
  242. GDK_TYPE_PIXBUF_ANIMATION));
  243. end;
  244. function GDK_IS_PIXBUF_ANIMATION(anObject : pointer) : boolean;
  245. begin
  246. GDK_IS_PIXBUF_ANIMATION:=G_TYPE_CHECK_INSTANCE_TYPE(anObject,
  247. GDK_TYPE_PIXBUF_ANIMATION);
  248. end;
  249. function GDK_TYPE_PIXBUF_ANIMATION_ITER : GType;
  250. begin
  251. GDK_TYPE_PIXBUF_ANIMATION_ITER:=gdk_pixbuf_animation_iter_get_type;
  252. end;
  253. function GDK_PIXBUF_ANIMATION_ITER(anObject : pointer) : PGdkPixbufAnimationIter;
  254. begin
  255. GDK_PIXBUF_ANIMATION_ITER:=PGdkPixbufAnimationIter(G_TYPE_CHECK_INSTANCE_CAST(
  256. anObject,GDK_TYPE_PIXBUF_ANIMATION_ITER));
  257. end;
  258. function GDK_IS_PIXBUF_ANIMATION_ITER(anObject : pointer) : boolean;
  259. begin
  260. GDK_IS_PIXBUF_ANIMATION_ITER:=G_TYPE_CHECK_INSTANCE_TYPE(anObject,
  261. GDK_TYPE_PIXBUF_ANIMATION_ITER);
  262. end;
  263. function GDK_PIXBUF_ERROR : TGQuark;
  264. begin
  265. GDK_PIXBUF_ERROR:=gdk_pixbuf_error_quark;
  266. end;
  267. end.