Commit 7ef5dec3 authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Arturo Espinosa

Removed the unref_fn field. Now all memory management of the buffer is

1999-10-20  Federico Mena Quintero  <federico@redhat.com>

	* src/gdk-pixbuf.h (GdkPixbuf): Removed the unref_fn field.  Now
	all memory management of the buffer is done by libart.

	* src/gdk-pixbuf.c (gdk_pixbuf_unref): Do destruction here.
	Removed gdk_pixbuf_destroy, gdk_pixbuf_duplicate.

	* src/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Implemented in
	terms of the libart functions.  Removed the old code.

	* src/gdk-pixbuf-io.c (image_handler_load): Removed the save
	symbols.  Saving will not be implemented in GdkPixbuf.

	* src/io-gif.c: Removed the saving stub.
	(image_load): Fixed memory management to fail gracefully if we run
	out of memory while loading the image.  Close the gif file when we
	are done.  This still needs more error handling for the DGif
	functions.

	* src/io-jpeg.c (image_load): Some robustness fixes.

	* src/io-png.c: Removed the saving stuff.
	(image_load): Some memory management fixes.

	* src/io-tiff.c (image_load): Ditto.

	* src/io-xpm.c (pixbuf_create_from_xpm): Ditto.
parent 46da5c2b
......@@ -185,7 +185,6 @@ static void
expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
{
GdkPixbuf *pixbuf;
gint x1, y1, x2, y2;
pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
......@@ -217,16 +216,17 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
static void
config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
{
GdkPixbuf *pixbuf, *spb;
GdkPixbuf *pixbuf;
pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
g_print("X:%d Y:%d\n", event->width, event->height);
#if 0
if (((event->width) != (pixbuf->art_pixbuf->width)) ||
((event->height) != (pixbuf->art_pixbuf->height)))
gdk_pixbuf_scale(pixbuf, event->width, event->height);
#endif
}
static void
......@@ -299,18 +299,18 @@ main (int argc, char **argv)
i = 1;
if (argc == 1) {
pixbuf = gdk_pixbuf_load_image_from_rgb_d(default_image,
DEFAULT_WIDTH,
DEFAULT_HEIGHT);
if (pixbuf) {
new_testrgb_window (pixbuf);
found_valid = TRUE;
}
pixbuf = gdk_pixbuf_new_from_data ((guchar *) default_image, ART_PIX_RGB, FALSE,
DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3,
NULL, NULL);
new_testrgb_window (pixbuf);
found_valid = TRUE;
} else {
for (i = 1; i < argc; i++) {
pixbuf = gdk_pixbuf_load_image (argv[i]);
pixbuf = gdk_pixbuf_new_from_file (argv[i]);
#if 0
pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0);
#endif
if (pixbuf) {
new_testrgb_window (pixbuf);
found_valid = TRUE;
......
1999-10-20 Federico Mena Quintero <federico@redhat.com>
* src/gdk-pixbuf.h (GdkPixbuf): Removed the unref_fn field. Now
all memory management of the buffer is done by libart.
* src/gdk-pixbuf.c (gdk_pixbuf_unref): Do destruction here.
Removed gdk_pixbuf_destroy, gdk_pixbuf_duplicate.
* src/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Implemented in
terms of the libart functions. Removed the old code.
* src/gdk-pixbuf-io.c (image_handler_load): Removed the save
symbols. Saving will not be implemented in GdkPixbuf.
* src/io-gif.c: Removed the saving stub.
(image_load): Fixed memory management to fail gracefully if we run
out of memory while loading the image. Close the gif file when we
are done. This still needs more error handling for the DGif
functions.
* src/io-jpeg.c (image_load): Some robustness fixes.
* src/io-png.c: Removed the saving stuff.
(image_load): Some memory management fixes.
* src/io-tiff.c (image_load): Ditto.
* src/io-xpm.c (pixbuf_create_from_xpm): Ditto.
1999-10-18 Havoc Pennington <hp@pobox.com>
* subautogen.sh: New name for macros/autogen.sh
......@@ -6,7 +35,9 @@
1999-10-18 Federico Mena Quintero <federico@redhat.com>
* src/*: Reindented to use the GNOME Indentation.
* src/*: Reindented to use the GNOME Indentation. Renamed
GdkPixBuf to GdkPixbuf, for consistency with the function names
(and it is also easier to type) :-)
1999-10-18 Havoc Pennington <hp@pobox.com>
......
lib_LTLIBRARIES = \
libgdk_pixbuf.la
......@@ -49,8 +48,7 @@ libgdk_pixbuf_la_SOURCES = \
gdk-pixbuf-data.c
libgdk_pixbufinclude_HEADERS = \
gdk-pixbuf.h \
gdk-pixbuf-io.h
gdk-pixbuf.h
#
# The PNG plugin.
......
/*
* gdk-pixbuf-data.c: Code to load images into GdkPixbufs from constant data
/* GdkPixbuf library - Image creation from in-memory buffers
*
* Author:
* Michael Fulbright (drmike@redhat.com)
* Copyright (C) 1999 Red Hat, Inc.
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "gdk-pixbuf.h"
/* This function does all the work. */
static GdkPixbuf *
_pixbuf_create_from_rgb_d(unsigned char *data, int w, int h)
/**
* gdk_pixbuf_new_from_data:
* @data: Image data in 8-bit/sample packed format.
* @format: Color format used for the data.
* @has_alpha: Whether the data has an opacity channel.
* @width: Width of the image in pixels.
* @height: Height of the image in pixels.
* @rowstride: Distance in bytes between rows.
* @dfunc: Function used to free the data when the pixbuf's reference count
* drops to zero, or NULL if the data should not be freed.
* @dfunc_data: Closure data to pass to the destroy notification function.
*
* Creates a new &GdkPixbuf out of in-memory RGB data.
*
* Return value: A newly-created &GdkPixbuf structure with a reference count of
* 1.
**/
GdkPixbuf *
gdk_pixbuf_new_from_data (guchar *data, ArtPixFormat format, gboolean has_alpha,
int width, int height, int rowstride,
ArtDestroyNotify dfunc, gpointer dfunc_data)
{
GdkPixbuf *pixbuf;
ArtPixBuf *art_pixbuf;
art_u8 *pixels;
pixels = art_alloc (w*h*3);
if (!pixels) {
g_warning ("RGBD: Cannot alloc ArtBuf");
return NULL;
}
memcpy (pixels, data, w*h*3);
/* Only 8-bit/sample RGB buffers are supported for now */
art_pixbuf = art_pixbuf_new_rgb (pixels, w, h, (w*3));
pixbuf = gdk_pixbuf_new (art_pixbuf, NULL);
if (!pixbuf)
art_free (pixels);
return pixbuf;
}
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (format == ART_PIX_RGB, NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
if (has_alpha)
art_pixbuf = art_pixbuf_new_rgba_dnotify (data, width, height, rowstride,
dfunc_data, dfunc);
else
art_pixbuf = art_pixbuf_new_rgb_dnotify (data, width, height, rowstride,
dfunc_data, dfunc);
GdkPixbuf *
gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, int rgb_width, int rgb_height)
{
g_return_val_if_fail (data != NULL, NULL);
g_assert (art_pixbuf != NULL);
return _pixbuf_create_from_rgb_d(data, rgb_width, rgb_height);
return gdk_pixbuf_new_from_art_pixbuf (art_pixbuf);
}
/*
* gdk-pixbuf-io.c: Code to load images into GdkPixbufs
/* GdkPixbuf library - Main loading interface.
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include <gmodule.h>
#include "gdk-pixbuf.h"
static gboolean
pixbuf_check_png (unsigned char *buffer, int size)
pixbuf_check_png (guchar *buffer, int size)
{
if (size < 28)
return FALSE;
......@@ -32,7 +49,7 @@ pixbuf_check_png (unsigned char *buffer, int size)
}
static gboolean
pixbuf_check_jpeg (unsigned char *buffer, int size)
pixbuf_check_jpeg (guchar *buffer, int size)
{
if (size < 10)
return FALSE;
......@@ -44,7 +61,7 @@ pixbuf_check_jpeg (unsigned char *buffer, int size)
}
static gboolean
pixbuf_check_tiff (unsigned char *buffer, int size)
pixbuf_check_tiff (guchar *buffer, int size)
{
if (size < 10)
return FALSE;
......@@ -65,7 +82,7 @@ pixbuf_check_tiff (unsigned char *buffer, int size)
}
static gboolean
pixbuf_check_gif (unsigned char *buffer, int size)
pixbuf_check_gif (guchar *buffer, int size)
{
if (size < 20)
return FALSE;
......@@ -77,7 +94,7 @@ pixbuf_check_gif (unsigned char *buffer, int size)
}
static gboolean
pixbuf_check_xpm (unsigned char *buffer, int size)
pixbuf_check_xpm (guchar *buffer, int size)
{
if (size < 20)
return FALSE;
......@@ -89,7 +106,7 @@ pixbuf_check_xpm (unsigned char *buffer, int size)
}
static gboolean
pixbuf_check_bmp (unsigned char *buffer, int size)
pixbuf_check_bmp (guchar *buffer, int size)
{
if (size < 20)
return FALSE;
......@@ -101,7 +118,7 @@ pixbuf_check_bmp (unsigned char *buffer, int size)
}
static gboolean
pixbuf_check_ppm (unsigned char *buffer, int size)
pixbuf_check_ppm (guchar *buffer, int size)
{
if (size < 20)
return FALSE;
......@@ -119,20 +136,21 @@ pixbuf_check_ppm (unsigned char *buffer, int size)
}
static struct {
char *module_name;
gboolean (*format_check)(unsigned char *buffer, int size);
GModule *module;
GdkPixbuf *(*load)(FILE *f);
int (*save)(GdkPixbuf *p, FILE *f, ...);
char *module_name;
gboolean (* format_check) (guchar *buffer, int size);
GModule *module;
GdkPixbuf *(* load) (FILE *f);
} file_formats [] = {
{ "png", pixbuf_check_png, NULL, NULL, NULL },
{ "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL },
{ "tiff", pixbuf_check_tiff, NULL, NULL, NULL },
{ "gif", pixbuf_check_gif, NULL, NULL, NULL },
{ "xpm", pixbuf_check_xpm, NULL, NULL, NULL },
/* { "bmp", pixbuf_check_bmp, NULL, NULL, NULL },
{ "ppm", pixbuf_check_ppm, NULL, NULL, NULL },*/
{ NULL, NULL, NULL, NULL, NULL }
{ "png", pixbuf_check_png, NULL, NULL },
{ "jpeg", pixbuf_check_jpeg, NULL, NULL },
{ "tiff", pixbuf_check_tiff, NULL, NULL },
{ "gif", pixbuf_check_gif, NULL, NULL },
{ "xpm", pixbuf_check_xpm, NULL, NULL },
#if 0
{ "bmp", pixbuf_check_bmp, NULL, NULL },
{ "ppm", pixbuf_check_ppm, NULL, NULL },
#endif
{ NULL, NULL, NULL, NULL }
};
static void
......@@ -141,10 +159,9 @@ image_handler_load (int idx)
char *module_name;
char *path;
GModule *module;
void *load_sym, *save_sym;
void *load_sym;
module_name = g_strconcat ("pixbuf-",
file_formats [idx].module_name, NULL);
module_name = g_strconcat ("pixbuf-", file_formats [idx].module_name, NULL);
path = g_module_build_path (PIXBUF_LIBDIR, module_name);
g_free (module_name);
......@@ -158,22 +175,22 @@ image_handler_load (int idx)
if (g_module_symbol (module, "image_load", &load_sym))
file_formats [idx].load = load_sym;
if (g_module_symbol (module, "image_save", &save_sym))
file_formats [idx].save = save_sym;
}
GdkPixbuf *
gdk_pixbuf_load_image (const char *file)
gdk_pixbuf_new_from_file (const char *filename)
{
GdkPixbuf *pixbuf;
gint n, i;
FILE *f;
char buffer [128];
f = fopen (file, "r");
f = fopen (filename, "r");
if (!f)
return NULL;
n = fread (&buffer, 1, sizeof (buffer), f);
if (n == 0) {
......@@ -182,7 +199,7 @@ gdk_pixbuf_load_image (const char *file)
}
for (i = 0; file_formats [i].module_name; i++) {
if ((*file_formats [i].format_check)(buffer, n)) {
if ((* file_formats [i].format_check) (buffer, n)) {
if (!file_formats [i].load)
image_handler_load (i);
......@@ -191,15 +208,18 @@ gdk_pixbuf_load_image (const char *file)
return NULL;
}
fseek(f, 0, SEEK_SET);
pixbuf = (*file_formats [i].load)(f);
fseek (f, 0, SEEK_SET);
pixbuf = (* file_formats [i].load) (f);
fclose (f);
g_assert (pixbuf->ref_count != 0);
if (pixbuf)
g_assert (pixbuf->ref_count != 0);
return pixbuf;
}
}
fclose (f);
g_warning ("Unable to find handler for file: %s", file);
g_warning ("Unable to find handler for file: %s", filename);
return NULL;
}
GdkPixbuf *
gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
{
art_u8 *pixels;
gint rowstride;
double affine[6];
ArtAlphaGamma *alphagamma;
ArtPixBuf *art_pixbuf = NULL;
GdkPixbuf *copy = NULL;
alphagamma = NULL;
affine[1] = affine[2] = affine[4] = affine[5] = 0;
affine[0] = w / (double)(pixbuf->art_pixbuf->width);
affine[3] = h / (double)(pixbuf->art_pixbuf->height);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3;
pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
copy = gdk_pixbuf_new (art_pixbuf, NULL);
if (!copy)
art_free (pixels);
return copy;
}
GdkPixbuf *
gdk_pixbuf_rotate (GdkPixbuf *pixbuf, gdouble angle)
{
art_u8 *pixels;
gint rowstride, w, h;
gdouble rad;
double rot[6], trans[6], affine[6];
ArtAlphaGamma *alphagamma = NULL;
ArtPixBuf *art_pixbuf = NULL;
w = pixbuf->art_pixbuf->width;
h = pixbuf->art_pixbuf->height;
rad = (M_PI * angle / 180.0);
rot[0] = cos(rad);
rot[1] = sin(rad);
rot[2] = -sin(rad);
rot[3] = cos(rad);
rot[4] = rot[5] = 0;
trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0;
trans[4] = -(double)w / 2.0;
trans[5] = -(double)h / 2.0;
art_affine_multiply(rot, trans, rot);
trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0;
trans[4] = (double)w / 2.0;
trans[5] = (double)h / 2.0;
art_affine_multiply(affine, rot, trans);
g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2],
affine[3], affine[4], affine[5]);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3;
pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = art_pixbuf;
return pixbuf;
}
/* GdkPixbuf library
/* GdkPixbuf library - Basic memory management
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Carsten Haitzler <raster@rasterman.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -25,7 +24,6 @@
#include <config.h>
#include <math.h>
#include <glib.h>
#include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_affine.h>
#include <libart_lgpl/art_pixbuf.h>
......@@ -35,30 +33,15 @@
void
gdk_pixbuf_destroy (GdkPixbuf *pixbuf)
{
art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = NULL;
g_free (pixbuf);
}
GdkPixbuf *
gdk_pixbuf_new (ArtPixBuf *art_pixbuf, GdkPixbufUnrefFunc *unref_fn)
{
GdkPixbuf *pixbuf;
if (!art_pixbuf)
return NULL;
pixbuf = g_new (GdkPixbuf, 1);
pixbuf->ref_count = 1;
pixbuf->unref_fn = unref_fn;
pixbuf->art_pixbuf = art_pixbuf;
return pixbuf;
}
/* Reference counting */
/**
* gdk_pixbuf_ref:
* @pixbuf: A pixbuf.
*
* Adds a reference to a pixbuf. It must be released afterwards using
* gdk_pixbuf_unref().
**/
void
gdk_pixbuf_ref (GdkPixbuf *pixbuf)
{
......@@ -68,6 +51,13 @@ gdk_pixbuf_ref (GdkPixbuf *pixbuf)
pixbuf->ref_count++;
}
/**
* gdk_pixbuf_unref:
* @pixbuf: A pixbuf.
*
* Removes a reference from a pixbuf. It will be destroyed when the reference
* count drops to zero.
**/
void
gdk_pixbuf_unref (GdkPixbuf *pixbuf)
{
......@@ -76,113 +66,35 @@ gdk_pixbuf_unref (GdkPixbuf *pixbuf)
pixbuf->ref_count--;
if (pixbuf->ref_count == 0)
gdk_pixbuf_destroy (pixbuf);
if (pixbuf->ref_count == 0) {
art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = NULL;
g_free (pixbuf);
}
}
GdkPixbuf *
gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
{
art_u8 *pixels;
gint rowstride;
double affine[6];
ArtAlphaGamma *alphagamma;
ArtPixBuf *art_pixbuf = NULL;
GdkPixbuf *copy = NULL;
alphagamma = NULL;
affine[1] = affine[2] = affine[4] = affine[5] = 0;
affine[0] = w / (double)(pixbuf->art_pixbuf->width);
affine[3] = h / (double)(pixbuf->art_pixbuf->height);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3;
pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
copy = gdk_pixbuf_new (art_pixbuf, NULL);
if (!copy)
art_free (pixels);
return copy;
}
GdkPixbuf *
gdk_pixbuf_duplicate (const GdkPixbuf *pixbuf)
{
GdkPixbuf *copy = g_new (GdkPixbuf, 1);
copy->ref_count = 1;
copy->unref_fn = pixbuf->unref_fn;
copy->art_pixbuf = art_pixbuf_duplicate (pixbuf->art_pixbuf);
return copy;
}
/* Wrap a libart pixbuf */
/**
* gdk_pixbuf_new_from_art_pixbuf:
* @art_pixbuf: A libart pixbuf.
*
* Creates a &GdkPixbuf by wrapping a libart pixbuf.
*
* Return value: A newly-created &GdkPixbuf structure with a reference count of
* 1.
**/
GdkPixbuf *
gdk_pixbuf_rotate (GdkPixbuf *pixbuf, gdouble angle)
gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf)
{
art_u8 *pixels;
gint rowstride, w, h;
gdouble rad;
double rot[6], trans[6], affine[6];
ArtAlphaGamma *alphagamma = NULL;
ArtPixBuf *art_pixbuf = NULL;
w = pixbuf->art_pixbuf->width;
h = pixbuf->art_pixbuf->height;
rad = (M_PI * angle / 180.0);
rot[0] = cos(rad);
rot[1] = sin(rad);
rot[2] = -sin(rad);
rot[3] = cos(rad);
rot[4] = rot[5] = 0;
trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0;
trans[4] = -(double)w / 2.0;
trans[5] = -(double)h / 2.0;
art_affine_multiply(rot, trans, rot);
trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0;
trans[4] = (double)w / 2.0;
trans[5] = (double)h / 2.0;
art_affine_multiply(affine, rot, trans);
g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2],
affine[3], affine[4], affine[5]);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3;
GdkPixbuf *pixbuf;
pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
g_return_val_if_fail (art_pixbuf != NULL, NULL);
art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf = g_new (GdkPixbuf, 1);
pixbuf->ref_count = 1;
pixbuf->art_pixbuf = art_pixbuf;
return pixbuf;
......
/* GdkPixbuf library
/* GdkPixbuf library - Main header file
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>