]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf-data.c
add a 'paned' mode to the function to let it draw the seven dots, instead
[~andy/gtk] / gdk-pixbuf / gdk-pixbuf-data.c
1 /* GdkPixbuf library - Image creation from in-memory buffers
2  *
3  * Copyright (C) 1999 The Free Software Foundation
4  *
5  * Author: Federico Mena-Quintero <federico@gimp.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <config.h>
24 #include "gdk-pixbuf.h"
25
26 \f
27
28 /**
29  * gdk_pixbuf_new_from_data:
30  * @data: Image data in 8-bit/sample packed format.
31  * @format: Color format used for the data.
32  * @has_alpha: Whether the data has an opacity channel.
33  * @width: Width of the image in pixels.
34  * @height: Height of the image in pixels.
35  * @rowstride: Distance in bytes between rows.
36  * @dfunc: Function used to free the data when the pixbuf's reference count
37  * drops to zero, or NULL if the data should not be freed.
38  * @dfunc_data: Closure data to pass to the destroy notification function.
39  * 
40  * Creates a new #GdkPixbuf out of in-memory RGB data.
41  * 
42  * Return value: A newly-created #GdkPixbuf structure with a reference count of
43  * 1.
44  **/
45 GdkPixbuf *
46 gdk_pixbuf_new_from_data (const guchar *data, ArtPixFormat format, gboolean has_alpha,
47                           int width, int height, int rowstride,
48                           ArtDestroyNotify dfunc, gpointer dfunc_data)
49 {
50         ArtPixBuf *art_pixbuf;
51
52         /* Only 8-bit/sample RGB buffers are supported for now */
53
54         g_return_val_if_fail (data != NULL, NULL);
55         g_return_val_if_fail (format == ART_PIX_RGB, NULL);
56         g_return_val_if_fail (width > 0, NULL);
57         g_return_val_if_fail (height > 0, NULL);
58
59         if (has_alpha)
60                 art_pixbuf = art_pixbuf_new_rgba_dnotify ((art_u8 *)data, width, height, rowstride,
61                                                           dfunc_data, dfunc);
62         else
63                 art_pixbuf = art_pixbuf_new_rgb_dnotify ((art_u8 *)data, width, height, rowstride,
64                                                          dfunc_data, dfunc);
65
66         g_assert (art_pixbuf != NULL);
67
68         return gdk_pixbuf_new_from_art_pixbuf (art_pixbuf);
69 }