1 /* Libart_LGPL - library of basic graphic primitives
2 * Copyright (C) 1998 Raph Levien
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 2 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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
20 #ifndef __ART_PIXBUF_H__
21 #define __ART_PIXBUF_H__
23 /* A generic data structure for holding a buffer of pixels. One way
24 to think about this module is as a virtualization over specific
25 pixel buffer formats. */
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
32 typedef void (*ArtDestroyNotify) (void *func_data, void *data);
34 typedef struct _ArtPixBuf ArtPixBuf;
36 typedef enum {
37 ART_PIX_RGB
38 /* gray, cmyk, lab, ... ? */
39 } ArtPixFormat;
42 /* The pixel buffer consists of width * height pixels, each of which
43 has n_channels samples. It is stored in simple packed format. */
45 struct _ArtPixBuf {
46 /*< public >*/
47 ArtPixFormat format;
48 int n_channels;
49 int has_alpha;
50 int bits_per_sample;
52 art_u8 *pixels;
53 int width;
54 int height;
55 int rowstride;
56 void *destroy_data;
57 ArtDestroyNotify destroy;
58 };
60 /* allocate an ArtPixBuf from art_alloc()ed pixels (automated destruction) */
61 ArtPixBuf *
62 art_pixbuf_new_rgb (art_u8 *pixels, int width, int height, int rowstride);
64 ArtPixBuf *
65 art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride);
67 /* allocate an ArtPixBuf from constant pixels (no destruction) */
68 ArtPixBuf *
69 art_pixbuf_new_const_rgb (const art_u8 *pixels, int width, int height, int rowstride);
71 ArtPixBuf *
72 art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride);
74 /* allocate an ArtPixBuf and notify creator upon destruction */
75 ArtPixBuf *
76 art_pixbuf_new_rgb_dnotify (art_u8 *pixels, int width, int height, int rowstride,
77 void *dfunc_data, ArtDestroyNotify dfunc);
79 ArtPixBuf *
80 art_pixbuf_new_rgba_dnotify (art_u8 *pixels, int width, int height, int rowstride,
81 void *dfunc_data, ArtDestroyNotify dfunc);
83 /* free an ArtPixBuf with destroy notification */
84 void
85 art_pixbuf_free (ArtPixBuf *pixbuf);
87 /* deprecated function, use the _dnotify variants for allocation instead */
88 void
89 art_pixbuf_free_shallow (ArtPixBuf *pixbuf);
91 ArtPixBuf *
92 art_pixbuf_duplicate (const ArtPixBuf *pixbuf);
94 #ifdef __cplusplus
95 }
96 #endif
98 #endif