replaced libart with new polygon code
[swftools.git] / lib / art / 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 LIBART_COMPILATION
28 #include "art_misc.h"
29 #else
30 #include "art_misc.h"
31 #endif
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37
38 typedef void (*ArtDestroyNotify) (void *func_data, void *data);
39
40 typedef struct _ArtPixBuf ArtPixBuf;
41
42 typedef enum {
43   ART_PIX_RGB
44   /* gray, cmyk, lab, ... ? */
45 } ArtPixFormat;
46
47
48 /* The pixel buffer consists of width * height pixels, each of which
49    has n_channels samples. It is stored in simple packed format. */
50
51 struct _ArtPixBuf {
52   /*< public >*/
53   ArtPixFormat format;
54   int n_channels;
55   int has_alpha;
56   int bits_per_sample;
57
58   art_u8 *pixels;
59   int width;
60   int height;
61   int rowstride;
62   void *destroy_data;
63   ArtDestroyNotify destroy;
64 };
65
66 /* allocate an ArtPixBuf from art_alloc()ed pixels (automated destruction) */
67 ArtPixBuf *
68 art_pixbuf_new_rgb (art_u8 *pixels, int width, int height, int rowstride);
69
70 ArtPixBuf *
71 art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride);
72
73 /* allocate an ArtPixBuf from constant pixels (no destruction) */
74 ArtPixBuf *
75 art_pixbuf_new_const_rgb (const art_u8 *pixels, int width, int height, int rowstride);
76
77 ArtPixBuf *
78 art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride);
79
80 /* allocate an ArtPixBuf and notify creator upon destruction */
81 ArtPixBuf *
82 art_pixbuf_new_rgb_dnotify (art_u8 *pixels, int width, int height, int rowstride,
83                             void *dfunc_data, ArtDestroyNotify dfunc);
84
85 ArtPixBuf *
86 art_pixbuf_new_rgba_dnotify (art_u8 *pixels, int width, int height, int rowstride,
87                              void *dfunc_data, ArtDestroyNotify dfunc);
88
89 /* free an ArtPixBuf with destroy notification */
90 void
91 art_pixbuf_free (ArtPixBuf *pixbuf);
92
93 /* deprecated function, use the _dnotify variants for allocation instead */
94 void
95 art_pixbuf_free_shallow (ArtPixBuf *pixbuf);
96
97 ArtPixBuf *
98 art_pixbuf_duplicate (const ArtPixBuf *pixbuf);
99
100 #ifdef __cplusplus
101 }
102 #endif
103
104 #endif