1 /* GdkPixbuf library - Image creation from in-memory buffers
3 * Copyright (C) 1999 The Free Software Foundation
5 * Author: Federico Mena-Quintero <federico@gimp.org>
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.
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.
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.
24 #include "gdk-pixbuf.h"
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.
40 * Creates a new #GdkPixbuf out of in-memory RGB data.
42 * Return value: A newly-created #GdkPixbuf structure with a reference count of
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)
50 ArtPixBuf *art_pixbuf;
52 /* Only 8-bit/sample RGB buffers are supported for now */
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);
60 art_pixbuf = art_pixbuf_new_rgba_dnotify ((art_u8 *)data, width, height, rowstride,
63 art_pixbuf = art_pixbuf_new_rgb_dnotify ((art_u8 *)data, width, height, rowstride,
66 g_assert (art_pixbuf != NULL);
68 return gdk_pixbuf_new_from_art_pixbuf (art_pixbuf);