gdip-pixbuf-loader r10 - in trunk: . src
- From: doml svn gnome org
- To: svn-commits-list gnome org
- Subject: gdip-pixbuf-loader r10 - in trunk: . src
- Date: Mon, 18 Feb 2008 17:23:55 +0000 (GMT)
Author: doml
Date: Mon Feb 18 17:23:55 2008
New Revision: 10
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=10&view=rev
Log:
2008-02-18 Dominic Lachowicz <domlachowicz gmail com>
* src/io-gdip.c (gdk_pixbuf__gdip_image_stop_load): Destroy the context
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 17:23:55 2008
@@ -41,7 +41,7 @@
gpointer user_data;
- gpointer buffer;
+ GByteArray* buffer;
};
typedef struct _GdipContext GdipContext;
@@ -49,6 +49,16 @@
G_MODULE_EXPORT void fill_info (GdkPixbufFormat *info);
static void
+destroy_gdipcontext (GdipContext *context)
+{
+ if (context != NULL)
+ {
+ g_byte_array_free (context->buffer, TRUE);
+ g_free (context);
+ }
+}
+
+static void
emit_updated (GdipContext *context, GdkPixbuf *pixbuf)
{
if (context->updated_func != NULL)
@@ -66,7 +76,6 @@
(* context->prepared_func) (pixbuf, NULL, context->user_data);
}
-
static gpointer
gdk_pixbuf__gdip_image_begin_load (GdkPixbufModuleSizeFunc size_func,
GdkPixbufModulePreparedFunc prepared_func,
@@ -95,12 +104,10 @@
return context;
}
-
-
static gboolean
gdk_pixbuf__gdip_image_load_increment (gpointer data,
- const guchar *buf, guint size,
- GError **error)
+ const guchar *buf, guint size,
+ GError **error)
{
GdipContext *context = (GdipContext *)data;
GByteArray *image_buffer = context->buffer;
@@ -108,10 +115,6 @@
if (error)
*error = NULL;
- /*if (context->first_write == TRUE) {
- context->first_write = FALSE;
- }*/
-
g_byte_array_append(image_buffer, (guint8*)buf, size);
return TRUE;
@@ -128,6 +131,8 @@
guint buffer_len = 0;
GdkPixbuf *pixbuf = NULL;
guchar *cursor = NULL;
+ gint rowstride;
+ gint n_channels;
gboolean result = TRUE;
@@ -141,16 +146,24 @@
bitmap = io_gdip_buffer_to_bitmap ((gchar*)image_buffer->data, image_buffer->len);
- //Destroy bytearray?
-
- if (!bitmap) return FALSE;
+ if (!bitmap)
+ {
+ destroy_gdipcontext (context);
+ return FALSE;
+ }
io_gdip_bitmap_get_size (bitmap, &width, &height);
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width+1, height+1);
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- if (!pixbuf) return FALSE;
-
- gdk_pixbuf_fill (pixbuf, 0xff33ff11);
+ if (!pixbuf)
+ {
+ destroy_gdipcontext (context);
+ return FALSE;
+ }
+
+ n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ cursor = gdk_pixbuf_get_pixels (pixbuf);
for (y = 0; y<=height; y++)
{
@@ -158,16 +171,10 @@
{
ARGB pixel;
guchar * channel;
- gint rowstride;
- gint n_channels;
pixel = io_gdip_bitmap_get_pixel (bitmap, x, y);
channel = (guchar*) &pixel;
- n_channels = gdk_pixbuf_get_n_channels (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- cursor = gdk_pixbuf_get_pixels (pixbuf);
-
if (y > 0) cursor += y * x * n_channels;
else cursor += x * n_channels;
@@ -181,12 +188,10 @@
}
}
-
emit_updated (context, pixbuf);
-
emit_prepared (context, pixbuf);
- // g_free (context);
+ destroy_gdipcontext (context);
return TRUE;
}
@@ -257,7 +262,7 @@
info->name = "Win32 GDI+";
info->signature = signature;
- info->description = "Win32 GDI+ Jpeg, Tiff and Png loader.";
+ info->description = "Win32 GDI+ JPEG, Tiff and PNG loader.";
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]