The BIG graph update
[rrdtool.git] / libraries / libart_lgpl-2.3.7 / art_pixbuf.h
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  */
19
20 #ifndef __ART_PIXBUF_H__
21 #define __ART_PIXBUF_H__
22
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. */
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31
32 typedef void (*ArtDestroyNotify) (void *func_data, void *data);
33
34 typedef struct _ArtPixBuf ArtPixBuf;
35
36 typedef enum {
37   ART_PIX_RGB
38   /* gray, cmyk, lab, ... ? */
39 } ArtPixFormat;
40
41
42 /* The pixel buffer consists of width * height pixels, each of which
43    has n_channels samples. It is stored in simple packed format. */
44
45 struct _ArtPixBuf {
46   /*< public >*/
47   ArtPixFormat format;
48   int n_channels;
49   int has_alpha;
50   int bits_per_sample;
51
52   art_u8 *pixels;
53   int width;
54   int height;
55   int rowstride;
56   void *destroy_data;
57   ArtDestroyNotify destroy;
58 };
59
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);
63
64 ArtPixBuf *
65 art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride);
66
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);
70
71 ArtPixBuf *
72 art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride);
73
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);
78
79 ArtPixBuf *
80 art_pixbuf_new_rgba_dnotify (art_u8 *pixels, int width, int height, int rowstride,
81                              void *dfunc_data, ArtDestroyNotify dfunc);
82
83 /* free an ArtPixBuf with destroy notification */
84 void
85 art_pixbuf_free (ArtPixBuf *pixbuf);
86
87 /* deprecated function, use the _dnotify variants for allocation instead */
88 void
89 art_pixbuf_free_shallow (ArtPixBuf *pixbuf);
90
91 ArtPixBuf *
92 art_pixbuf_duplicate (const ArtPixBuf *pixbuf);
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif