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



Author: doml
Date: Mon Feb 18 21:31:37 2008
New Revision: 15
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=15&view=rev

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

	* src/*.c: Whitespace fixes

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 21:31:37 2008
@@ -25,7 +25,6 @@
 #include <ole2.h>
 
 static HINSTANCE gdipluslib = NULL;
-static ULONG_PTR gdiplusToken = 0;
 
 /* ////// WRAPPER FUNCTIONS /////// */
 
@@ -121,6 +120,7 @@
 io_gdip_init (void)
 {
 	GdiplusStartupInput input;
+        ULONG_PTR gdiplusToken = 0;
 
 	input.GdiplusVersion = 1;
 	input.DebugEventCallback = NULL;
@@ -170,11 +170,11 @@
 	hr = CreateStreamOnHGlobal (hg, FALSE, (LPSTREAM*)&stream);
 
 	if (!SUCCEEDED(hr))
-	{
-		GlobalFree(hg);
-		return NULL;
-	}
-
+                {
+                        GlobalFree(hg);
+                        return NULL;
+                }
+        
 	status = GdipCreateBitmapFromStream(stream, &bitmap);
 
         IStream_Release(stream);

Modified: trunk/src/io-gdip.c
==============================================================================
--- trunk/src/io-gdip.c	(original)
+++ trunk/src/io-gdip.c	Mon Feb 18 21:31:37 2008
@@ -26,13 +26,6 @@
 #include <gdk-pixbuf/gdk-pixbuf-io.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-enum ARGBChannels {
-	ARGB_CHANNEL_ALPHA,
-	ARGB_CHANNEL_RED,
-	ARGB_CHANNEL_GREEN,
-	ARGB_CHANNEL_BLUE
-};
-
 struct _GdipContext{
         GdkPixbufModuleUpdatedFunc  updated_func;
         GdkPixbufModulePreparedFunc prepared_func;
@@ -54,10 +47,11 @@
                       const char * reason,
                       gint code)
 {
-        if (err) {
-                *err = NULL;
-                g_set_error (err, GDK_PIXBUF_ERROR, code, reason);
-        }
+        if (err) 
+                {
+                        *err = NULL;
+                        g_set_error (err, GDK_PIXBUF_ERROR, code, reason);
+                }
 }
 
 static void
@@ -90,10 +84,10 @@
 
 static gpointer
 gdk_pixbuf__gdip_image_begin_load (GdkPixbufModuleSizeFunc size_func,
-                                  GdkPixbufModulePreparedFunc prepared_func,
-                                  GdkPixbufModuleUpdatedFunc  updated_func,
-                                  gpointer user_data,
-                                  GError **error)
+                                   GdkPixbufModulePreparedFunc prepared_func,
+                                   GdkPixbufModuleUpdatedFunc  updated_func,
+                                   gpointer user_data,
+                                   GError **error)
 {
 	GdipContext *context = g_new(GdipContext, 1);
 
@@ -147,8 +141,6 @@
 	guchar            *cursor = NULL;
         gint rowstride;
 
-        gboolean          result = TRUE;
-
 	guint width = 0, height = 0, x, y;
 
         if (error)
@@ -181,69 +173,70 @@
         cursor = gdk_pixbuf_get_pixels (pixbuf);
 	
 	for (y = 0; y < height; y++)
-	{
-                guint8 *row_data = (cursor + (y * rowstride));
-
-		for (x = 0; x < width; x++)
-		{
-			ARGB pixel;
-                        guint8 alpha;
-                        guchar *b = cursor + (y * rowstride + (x * 4));
-
-			pixel = io_gdip_bitmap_get_pixel (bitmap, x, y);
-
-                        /* un-premultiply alpha */
-                        alpha = (pixel & 0xff000000) >> 24;
-                        if (alpha == 0) {
-                                b[0] = b[1] = b[2] = b[3] = 0;
-                        } else {
-                                b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
-                                b[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;
-                                b[2] = (((pixel & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha;
-                                b[3] = alpha;
-                        }                        
-		}
-	}
-
+                {
+                        for (x = 0; x < width; x++)
+                                {
+                                        ARGB pixel;
+                                        guint8 alpha;
+                                        guchar *b = cursor + (y * rowstride + (x * 4));
+                                        
+                                        pixel = io_gdip_bitmap_get_pixel (bitmap, x, y);
+                                        
+                                        /* un-premultiply alpha */
+                                        alpha = (pixel & 0xff000000) >> 24;
+                                        if (alpha == 0) 
+                                                {
+                                                        b[0] = b[1] = b[2] = b[3] = 0;
+                                                } 
+                                        else 
+                                                {
+                                                        b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
+                                                        b[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;
+                                                        b[2] = (((pixel & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha;
+                                                        b[3] = alpha;
+                                                }
+                                }
+                }
+        
         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;
-                                        }
-                        }
-        }
-
+                {
+                        gint w = width;
+                        gint h = height;
+                        
+                        (*context->size_func) (&w, &h, context->user_data);
+                        if (w == 0 || h == 0)
+                                {
+                                        destroy_gdipcontext (context);
+                                        g_object_unref (pixbuf);
+                                        gdip_propegate_error (error,
+                                                              "Transformed image has zero width or height.",
+                                                              GDK_PIXBUF_ERROR_FAILED);
+                                        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);
         
         destroy_gdipcontext (context);
-
+        
         return TRUE;
 }
 
@@ -312,7 +305,7 @@
         };
 
         info->name        = "Win32 GDI+";
-        info->signature = signature;
+        info->signature   = signature;
         info->description = "Win32 GDI+ JPEG, Tiff and PNG loader.";
         info->mime_types  = mime_types;
         info->extensions  = extensions;



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