gdip-pixbuf-loader r12 - in trunk: . src



Author: doml
Date: Mon Feb 18 17:54:47 2008
New Revision: 12
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=12&view=rev

Log:
2008-02-18  Dominic Lachowicz <domlachowicz gmail com>

	* src/io-gdip.c: Move initialization to fill_vtable
	* src/io-gdip-utils.c: GDI+ functions return Status, not HRESULT, so we can't use
	SUCCEEDED() to test if they worked or not

Modified:
   trunk/ChangeLog
   trunk/src/io-gdip-utils.c
   trunk/src/io-gdip.c

Modified: trunk/src/io-gdip-utils.c
==============================================================================
--- trunk/src/io-gdip-utils.c	(original)
+++ trunk/src/io-gdip-utils.c	Mon Feb 18 17:54:47 2008
@@ -120,7 +120,6 @@
 gboolean
 io_gdip_init (void)
 {
-	HRESULT hr;
 	GdiplusStartupInput input;
 
 	input.GdiplusVersion = 1;
@@ -133,13 +132,7 @@
 	if (!gdipluslib)
 		return FALSE;
 
-	hr = GdiplusStartup (&gdiplusToken, &input, NULL);
-	
-
-	if (!SUCCEEDED (hr))
-		return FALSE;
-
-	return TRUE;
+	return (GdiplusStartup (&gdiplusToken, &input, NULL) == 0 ? TRUE : FALSE);	
 }
 
 static HGLOBAL
@@ -168,6 +161,7 @@
 	HGLOBAL hg = NULL;
 	GpBitmap * bitmap = NULL;
 	IStream *stream = NULL;	
+        int status;
 
 	hg = io_gdip_buffer_to_hglobal (buffer, size);
 
@@ -181,16 +175,11 @@
 		return NULL;
 	}
 
-	hr = GdipCreateBitmapFromStream(stream, &bitmap);
+	status = GdipCreateBitmapFromStream(stream, &bitmap);
 
         IStream_Release(stream);
         GlobalFree(hg);
 
-	if (!SUCCEEDED(hr))
-	{
-		return NULL;
-	}
-
 	return bitmap;	
 }
 
@@ -202,6 +191,11 @@
 
 	GdipGetImageWidth ((GpImage*) bitmap, width);
 	GdipGetImageHeight ((GpImage*) bitmap, height);
+
+        /* for a 400x400 image, GDI+ returns 399x399 */
+        *width += 1;
+        *height += 1;
+
 	return TRUE;
 }
 

Modified: trunk/src/io-gdip.c
==============================================================================
--- trunk/src/io-gdip.c	(original)
+++ trunk/src/io-gdip.c	Mon Feb 18 17:54:47 2008
@@ -146,13 +146,14 @@
 
 	bitmap = io_gdip_buffer_to_bitmap ((gchar*)image_buffer->data, image_buffer->len);
 
-	if (!bitmap) 
+	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, height);
 
 	if (!pixbuf)
@@ -203,6 +204,8 @@
 void
 fill_vtable (GdkPixbufModule *module)
 {
+        io_gdip_init ();
+
         module->begin_load     = gdk_pixbuf__gdip_image_begin_load;
         module->stop_load      = gdk_pixbuf__gdip_image_stop_load;
         module->load_increment = gdk_pixbuf__gdip_image_load_increment;
@@ -262,8 +265,6 @@
                 NULL
         };
 
-        io_gdip_init ();
-
         info->name        = "Win32 GDI+";
         info->signature = signature;
         info->description = "Win32 GDI+ JPEG, Tiff and PNG loader.";



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]