Debian Codegraph @

gifenc/gifenc.h

raw symbols SCIP
1 /* simple gif encoder
2 * Copyright (C) 2005 Benjamin Otte <[email protected]
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <glib.h>
19 #include <gtk/gtk.h>
20
21 #ifndef __HAVE_GIFENC_H__
22 #define __HAVE_GIFENC_H__
23
24 typedef struct _GifencPalette GifencPalette;
25 typedef struct _GifencColor GifencColor;
26 typedef struct _Gifenc Gifenc;
27
28 typedef gboolean (* GifencWriteFunc) (gpointer closure, const guchar *data, gsize len, GError **error);
29
30 typedef enum {
31 GIFENC_STATE_NEW = 0,
32 GIFENC_STATE_INITIALIZED,
33 GIFENC_STATE_CLOSED,
34 } GifencState;
35
36 struct _GifencPalette {
37 gboolean alpha;
38 guint32 * colors;
39 guint num_colors;
40 guint byte_order;
41 gpointer data;
42 guint (* lookup) (gpointer data,
43 guint32 color,
44 guint32 * resulting_color);
45 void (* free) (gpointer data);
46 };
47
48 struct _Gifenc {
49 /* error checking */
50 GifencState state;
51
52 /* output */
53 GifencWriteFunc write_func;
54 gpointer write_data;
55 GDestroyNotify write_destroy;
56 GByteArray * buffer;
57 guint bits;
58 guint n_bits;
59
60 /* image */
61 guint width;
62 guint height;
63 guint byte_order;
64 GifencPalette * palette;
65 };
66
67 Gifenc * gifenc_new (guint width,
68 guint height,
69 GifencWriteFunc write_func,
70 gpointer write_data,
71 GDestroyNotify write_destroy);
72 gboolean gifenc_free (Gifenc * enc);
73
74 gboolean gifenc_initialize (Gifenc * enc,
75 GifencPalette * palette,
76 gboolean loop,
77 GError ** error);
78 gboolean gifenc_add_image (Gifenc * enc,
79 guint x,
80 guint y,
81 guint width,
82 guint height,
83 guint display_millis,
84 guint8 * data,
85 guint rowstride,
86 GError ** error);
87 gboolean gifenc_close (Gifenc * gifenc,
88 GError ** error);
89 guint gifenc_get_width (Gifenc * gifenc);
90 guint gifenc_get_height (Gifenc * gifenc);
91
92 void gifenc_dither_rgb (guint8 * target,
93 guint target_rowstride,
94 const GifencPalette * palette,
95 const guint8 * data,
96 guint width,
97 guint height,
98 guint rowstride);
99 gboolean gifenc_dither_rgb_with_full_image
100 (guint8 * target,
101 guint target_rowstride,
102 guint8 * full,
103 guint full_rowstride,
104 const GifencPalette * palette,
105 const guint8 * data,
106 guint width,
107 guint height,
108 guint rowstride,
109 cairo_rectangle_int_t * rect_out);
110
111 /* from quantize.c */
112 void gifenc_palette_free (GifencPalette * palette);
113 GifencPalette * gifenc_palette_get_simple (gboolean alpha);
114 GifencPalette * gifenc_quantize_image (const guint8 * data,
115 guint width,
116 guint height,
117 guint rowstride,
118 gboolean alpha,
119 guint max_colors);
120 guint gifenc_palette_get_alpha_index
121 (const GifencPalette * palette);
122 guint gifenc_palette_get_num_colors
123 (const GifencPalette * palette);
124 guint32 gifenc_palette_get_color(const GifencPalette * palette,
125 guint id);
126
127
128 #endif /* __HAVE_GIFENC_H__ */