gdip-pixbuf-loader r14 - in trunk: . src
- From: doml svn gnome org
- To: svn-commits-list gnome org
- Subject: gdip-pixbuf-loader r14 - in trunk: . src
- Date: Mon, 18 Feb 2008 18:39:51 +0000 (GMT)
Author: doml
Date: Mon Feb 18 18:39:51 2008
New Revision: 14
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=14&view=rev
Log:
2008-02-18 Dominic Lachowicz <domlachowicz gmail com>
* src/io-gdip.c: Support pixbuf scaling
Modified:
trunk/ChangeLog
trunk/src/io-gdip.c
Modified: trunk/src/io-gdip.c
==============================================================================
--- trunk/src/io-gdip.c (original)
+++ trunk/src/io-gdip.c Mon Feb 18 18:39:51 2008
@@ -24,6 +24,7 @@
#define GDK_PIXBUF_ENABLE_BACKEND
#include <gdk-pixbuf/gdk-pixbuf-io.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
enum ARGBChannels {
ARGB_CHANNEL_ALPHA,
@@ -98,7 +99,7 @@
if (!context)
{
- gdip_propegate_error (error, "Couldn't create context", 0);
+ gdip_propegate_error (error, "Couldn't create context", GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY);
return NULL;
}
@@ -161,7 +162,7 @@
if (!bitmap)
{
destroy_gdipcontext (context);
- gdip_propegate_error (error, "Couldn't load bitmap", 0);
+ gdip_propegate_error (error, "Couldn't load bitmap", GDK_PIXBUF_ERROR_CORRUPT_IMAGE);
return FALSE;
}
@@ -172,7 +173,7 @@
if (!pixbuf)
{
destroy_gdipcontext (context);
- gdip_propegate_error (error, "Couldn't create Pixbuf", 0);
+ gdip_propegate_error (error, "Couldn't create pixbuf", GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY);
return FALSE;
}
@@ -204,6 +205,40 @@
}
}
+ if (context->size_func)
+ {
+ gint w = width;
+ gint h = height;
+
+ (*context->size_func) (&w, &h, context->user_data);
+ if (w == 0 || h == 0)
+ {
+ destroy_gdipcontext (context);
+ gdip_propegate_error (error,
+ "Transformed image has zero width or height.",
+ GDK_PIXBUF_ERROR_FAILED);
+ g_object_unref (pixbuf);
+ return FALSE;
+
+ }
+ else if (w != width || h != height)
+ {
+ GdkPixbuf *new_pixbuf;
+
+ new_pixbuf = gdk_pixbuf_scale_simple (pixbuf, w, h, GDK_INTERP_BILINEAR);
+
+ g_object_unref (pixbuf);
+ pixbuf = new_pixbuf;
+
+ if (pixbuf == NULL)
+ {
+ destroy_gdipcontext (context);
+ gdip_propegate_error (error, "Couldn't scale pixbuf", GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY);
+ return FALSE;
+ }
+ }
+ }
+
emit_updated (context, pixbuf);
emit_prepared (context, pixbuf);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]