You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

268 lines
9.3 KiB

  1. /* GdkPixbuf library - GdkPixbuf data structure
  2. *
  3. * Copyright (C) 2003 The Free Software Foundation
  4. *
  5. * Authors: Mark Crichton <crichton@gimp.org>
  6. * Miguel de Icaza <miguel@gnu.org>
  7. * Federico Mena-Quintero <federico@gimp.org>
  8. * Havoc Pennington <hp@redhat.com>
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2 of the License, or (at your option) any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the
  22. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. * Boston, MA 02111-1307, USA.
  24. */
  25. #if defined(GDK_PIXBUF_DISABLE_SINGLE_INCLUDES) && !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
  26. #error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
  27. #endif
  28. #ifndef GDK_PIXBUF_CORE_H
  29. #define GDK_PIXBUF_CORE_H
  30. #include <glib.h>
  31. #include <glib-object.h>
  32. #include <gio/gio.h>
  33. G_BEGIN_DECLS
  34. /* Alpha compositing mode */
  35. typedef enum
  36. {
  37. GDK_PIXBUF_ALPHA_BILEVEL,
  38. GDK_PIXBUF_ALPHA_FULL
  39. } GdkPixbufAlphaMode;
  40. /* Color spaces; right now only RGB is supported.
  41. * Note that these values are encoded in inline pixbufs
  42. * as ints, so don't reorder them
  43. */
  44. typedef enum {
  45. GDK_COLORSPACE_RGB
  46. } GdkColorspace;
  47. /* All of these are opaque structures */
  48. typedef struct _GdkPixbuf GdkPixbuf;
  49. #define GDK_TYPE_PIXBUF (gdk_pixbuf_get_type ())
  50. #define GDK_PIXBUF(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
  51. #define GDK_IS_PIXBUF(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
  52. /* Handler that must free the pixel array */
  53. typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
  54. #define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()
  55. typedef enum {
  56. /* image data hosed */
  57. GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
  58. /* no mem to load image */
  59. GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
  60. /* bad option passed to save routine */
  61. GDK_PIXBUF_ERROR_BAD_OPTION,
  62. /* unsupported image type (sort of an ENOSYS) */
  63. GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
  64. /* unsupported operation (load, save) for image type */
  65. GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
  66. GDK_PIXBUF_ERROR_FAILED
  67. } GdkPixbufError;
  68. GQuark gdk_pixbuf_error_quark (void);
  69. GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
  70. /* Reference counting */
  71. #ifndef GDK_PIXBUF_DISABLE_DEPRECATED
  72. GdkPixbuf *gdk_pixbuf_ref (GdkPixbuf *pixbuf);
  73. void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
  74. #endif
  75. /* GdkPixbuf accessors */
  76. GdkColorspace gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf);
  77. int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf);
  78. gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf);
  79. int gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
  80. guchar *gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf);
  81. int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf);
  82. int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf);
  83. int gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf);
  84. /* Create a blank pixbuf with an optimal rowstride and a new buffer */
  85. GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
  86. int width, int height);
  87. /* Copy a pixbuf */
  88. GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
  89. /* Create a pixbuf which points to the pixels of another pixbuf */
  90. GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
  91. int src_x,
  92. int src_y,
  93. int width,
  94. int height);
  95. /* Simple loading */
  96. #ifdef G_OS_WIN32
  97. /* DLL ABI stability hack. */
  98. #define gdk_pixbuf_new_from_file gdk_pixbuf_new_from_file_utf8
  99. #define gdk_pixbuf_new_from_file_at_size gdk_pixbuf_new_from_file_at_size_utf8
  100. #define gdk_pixbuf_new_from_file_at_scale gdk_pixbuf_new_from_file_at_scale_utf8
  101. #endif
  102. GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
  103. GError **error);
  104. GdkPixbuf *gdk_pixbuf_new_from_file_at_size (const char *filename,
  105. int width,
  106. int height,
  107. GError **error);
  108. GdkPixbuf *gdk_pixbuf_new_from_file_at_scale (const char *filename,
  109. int width,
  110. int height,
  111. gboolean preserve_aspect_ratio,
  112. GError **error);
  113. GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
  114. GdkColorspace colorspace,
  115. gboolean has_alpha,
  116. int bits_per_sample,
  117. int width, int height,
  118. int rowstride,
  119. GdkPixbufDestroyNotify destroy_fn,
  120. gpointer destroy_fn_data);
  121. GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
  122. GdkPixbuf* gdk_pixbuf_new_from_inline (gint data_length,
  123. const guint8 *data,
  124. gboolean copy_pixels,
  125. GError **error);
  126. /* Mutations */
  127. void gdk_pixbuf_fill (GdkPixbuf *pixbuf,
  128. guint32 pixel);
  129. /* Saving */
  130. #ifdef G_OS_WIN32
  131. /* DLL ABI stability hack. */
  132. #define gdk_pixbuf_save gdk_pixbuf_save_utf8
  133. #define gdk_pixbuf_savev gdk_pixbuf_savev_utf8
  134. #endif
  135. gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf,
  136. const char *filename,
  137. const char *type,
  138. GError **error,
  139. ...) G_GNUC_NULL_TERMINATED;
  140. gboolean gdk_pixbuf_savev (GdkPixbuf *pixbuf,
  141. const char *filename,
  142. const char *type,
  143. char **option_keys,
  144. char **option_values,
  145. GError **error);
  146. /* Saving to a callback function */
  147. typedef gboolean (*GdkPixbufSaveFunc) (const gchar *buf,
  148. gsize count,
  149. GError **error,
  150. gpointer data);
  151. gboolean gdk_pixbuf_save_to_callback (GdkPixbuf *pixbuf,
  152. GdkPixbufSaveFunc save_func,
  153. gpointer user_data,
  154. const char *type,
  155. GError **error,
  156. ...) G_GNUC_NULL_TERMINATED;
  157. gboolean gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf,
  158. GdkPixbufSaveFunc save_func,
  159. gpointer user_data,
  160. const char *type,
  161. char **option_keys,
  162. char **option_values,
  163. GError **error);
  164. /* Saving into a newly allocated char array */
  165. gboolean gdk_pixbuf_save_to_buffer (GdkPixbuf *pixbuf,
  166. gchar **buffer,
  167. gsize *buffer_size,
  168. const char *type,
  169. GError **error,
  170. ...) G_GNUC_NULL_TERMINATED;
  171. gboolean gdk_pixbuf_save_to_bufferv (GdkPixbuf *pixbuf,
  172. gchar **buffer,
  173. gsize *buffer_size,
  174. const char *type,
  175. char **option_keys,
  176. char **option_values,
  177. GError **error);
  178. GdkPixbuf *gdk_pixbuf_new_from_stream (GInputStream *stream,
  179. GCancellable *cancellable,
  180. GError **error);
  181. GdkPixbuf *gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
  182. gint width,
  183. gint height,
  184. gboolean preserve_aspect_ratio,
  185. GCancellable *cancellable,
  186. GError **error);
  187. gboolean gdk_pixbuf_save_to_stream (GdkPixbuf *pixbuf,
  188. GOutputStream *stream,
  189. const char *type,
  190. GCancellable *cancellable,
  191. GError **error,
  192. ...);
  193. /* Adding an alpha channel */
  194. GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
  195. guchar r, guchar g, guchar b);
  196. /* Copy an area of a pixbuf onto another one */
  197. void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
  198. int src_x, int src_y,
  199. int width, int height,
  200. GdkPixbuf *dest_pixbuf,
  201. int dest_x, int dest_y);
  202. /* Brighten/darken and optionally make it pixelated-looking */
  203. void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
  204. GdkPixbuf *dest,
  205. gfloat saturation,
  206. gboolean pixelate);
  207. /* Transform an image to agree with its embedded orientation option / tag */
  208. GdkPixbuf *gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src);
  209. G_CONST_RETURN gchar * gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
  210. const gchar *key);
  211. G_END_DECLS
  212. #endif /* GDK_PIXBUF_CORE_H */