]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
finished work to make animated gifs load correctly. Progressive loading
[~andy/gtk] / gdk-pixbuf / gdk-pixbuf.h
1 /* GdkPixbuf library - Main header file
2  *
3  * Copyright (C) 1999 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  *
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  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #ifndef GDK_PIXBUF_H
26 #define GDK_PIXBUF_H
27
28 #include <libart_lgpl/art_misc.h>
29 #include <libart_lgpl/art_pixbuf.h>
30 #include <gdk/gdk.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 \f
37
38 /* GdkPixbuf structures */
39 typedef struct _GdkPixbuf GdkPixbuf;
40 typedef struct _GdkPixbufFrame GdkPixbufFrame;
41 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
42
43 typedef enum
44 {
45         GDK_PIXBUF_FRAME_RETAIN,
46         GDK_PIXBUF_FRAME_DISPOSE,
47         GDK_PIXBUF_FRAME_REVERT
48 } GdkPixbufFrameAction;
49
50 struct _GdkPixbuf
51 {
52         /* Reference count */
53         int ref_count;
54
55         /* Libart pixbuf */
56         ArtPixBuf *art_pixbuf;
57 };
58
59
60 struct _GdkPixbufFrame
61 {
62         GdkPixbuf *pixbuf;
63
64         gushort x_offset;
65         gushort y_offset;
66         gint delay_time;
67         GdkPixbufFrameAction action;
68 };
69
70
71 struct _GdkPixbufAnimation
72 {
73         int n_frames;
74         GList *frames;
75 };
76
77 \f
78
79 /* Convenience functions */
80
81 ArtPixFormat gdk_pixbuf_get_format          (GdkPixbuf *pixbuf);
82 int          gdk_pixbuf_get_n_channels      (GdkPixbuf *pixbuf);
83 int          gdk_pixbuf_get_has_alpha       (GdkPixbuf *pixbuf);
84 int          gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf);
85 guchar      *gdk_pixbuf_get_pixels          (GdkPixbuf *pixbuf);
86 int          gdk_pixbuf_get_width           (GdkPixbuf *pixbuf);
87 int          gdk_pixbuf_get_height          (GdkPixbuf *pixbuf);
88 int          gdk_pixbuf_get_rowstride       (GdkPixbuf *pixbuf);
89
90 /* Reference counting */
91
92 void gdk_pixbuf_ref (GdkPixbuf *pixbuf);
93 void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
94
95 /* Constructors */
96 /* Wrap a libart pixbuf */
97
98 GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);
99
100 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
101
102 GdkPixbuf *gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
103                            int width, int height);
104
105 /* Simple loading */
106
107 GdkPixbuf *gdk_pixbuf_new_from_file     (const char        *filename);
108 GdkPixbuf *gdk_pixbuf_new_from_data     (guchar *data,
109                                          ArtPixFormat format,
110                                          gboolean has_alpha,
111                                          int width, int height,
112                                          int rowstride,
113                                          ArtDestroyNotify dfunc,
114                                          gpointer dfunc_data);
115 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const gchar      **data);
116
117 /* Adding or removing alpha */
118
119 GdkPixbuf *gdk_pixbuf_add_alpha (GdkPixbuf *pixbuf, gboolean substitute_color,
120                                  guchar r, guchar g, guchar b);
121
122 /* Rendering to a drawable */
123
124 typedef enum {
125         GDK_PIXBUF_ALPHA_BILEVEL,
126         GDK_PIXBUF_ALPHA_FULL
127 } GdkPixbufAlphaMode;
128
129 void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
130                                         int src_x, int src_y,
131                                         int dest_x, int dest_y,
132                                         int width, int height,
133                                         int alpha_threshold);
134
135 void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
136                                     GdkDrawable *drawable, GdkGC *gc,
137                                     int src_x, int src_y,
138                                     int dest_x, int dest_y,
139                                     int width, int height,
140                                     GdkRgbDither dither,
141                                     int x_dither, int y_dither);
142
143 void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
144                                           int src_x, int src_y,
145                                           int dest_x, int dest_y,
146                                           int width, int height,
147                                           GdkPixbufAlphaMode alpha_mode,
148                                           int alpha_threshold,
149                                           GdkRgbDither dither,
150                                           int x_dither, int y_dither);
151
152
153 /* Fetching a region from a drawable */
154 GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
155                                          GdkDrawable *src, GdkColormap *cmap,
156                                          int src_x, int src_y,
157                                          int dest_x, int dest_y,
158                                          int width, int height);
159
160 \f
161
162 /* Animation loading */
163
164 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char         *filename);
165 void                gdk_pixbuf_animation_destroy       (GdkPixbufAnimation *animation,
166                                                         gboolean            free_frames);
167
168
169 \f
170
171 #ifdef __cplusplus
172 }
173 #endif
174
175 #endif