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



Author: doml
Date: Sat Mar 15 15:39:40 2008
New Revision: 46
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=46&view=rev

Log:
2008-03-15  Dominic Lachowicz <domlachowicz gmail com>

	* io-gdip.c: Remove
	* io-gdip-ico.c:
	* io-gdip-wmf.c:
	* io-gdip-emf.c: Separate these into their own loaders, so that existing
	code that calls "gdk_pixbuf_loader_for_type()" and friends continues
	to work as expected.
	* Makefile.test:
	* Makefile.am: Reflect the above changes
	* io-gdip-native.h:
	* io-gdip-utils.c: Better error reporting; handle metafiles properly
	(loading them as bitmaps doesn't work; you have to load them as a
	generic image or metafile and then draw them onto a bitmap)

Added:
   trunk/src/io-gdip-emf.c
   trunk/src/io-gdip-ico.c
   trunk/src/io-gdip-wmf.c
Removed:
   trunk/src/io-gdip.c
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/Makefile.test
   trunk/src/io-gdip-native.h
   trunk/src/io-gdip-utils.c
   trunk/src/io-gdip-utils.h

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sat Mar 15 15:39:40 2008
@@ -6,15 +6,35 @@
 	libpixbufloader-gdip-png.la	\
 	libpixbufloader-gdip-tiff.la
 
-libpixbufloader_gdip_la_LDFLAGS = -avoid-version -module -no-undefined
-libpixbufloader_gdip_la_SOURCES = 	\
+libpixbufloader_gdip_ico_la_LDFLAGS = -avoid-version -module -no-undefined
+libpixbufloader_gdip_ico_la_SOURCES = 	\
 	io-gdip-native.h		\
 	io-gdip-propertytags.h		\
 	io-gdip-utils.h			\
 	io-gdip-utils.c			\
 	io-gdip-animation.c		\
 	io-gdip-animation.h		\
-	io-gdip.c
+	io-gdip-ico.c
+
+libpixbufloader_gdip_wmf_la_LDFLAGS = -avoid-version -module -no-undefined
+libpixbufloader_gdip_wmf_la_SOURCES = 	\
+	io-gdip-native.h		\
+	io-gdip-propertytags.h		\
+	io-gdip-utils.h			\
+	io-gdip-utils.c			\
+	io-gdip-animation.c		\
+	io-gdip-animation.h		\
+	io-gdip-wmf.c
+
+libpixbufloader_gdip_emf_la_LDFLAGS = -avoid-version -module -no-undefined
+libpixbufloader_gdip_emf_la_SOURCES = 	\
+	io-gdip-native.h		\
+	io-gdip-propertytags.h		\
+	io-gdip-utils.h			\
+	io-gdip-utils.c			\
+	io-gdip-animation.c		\
+	io-gdip-animation.h		\
+	io-gdip-emf.c
 
 libpixbufloader_gdip_bmp_la_LDFLAGS = -avoid-version -module -no-undefined
 libpixbufloader_gdip_bmp_la_SOURCES = 	\

Modified: trunk/src/Makefile.test
==============================================================================
--- trunk/src/Makefile.test	(original)
+++ trunk/src/Makefile.test	Sat Mar 15 15:39:40 2008
@@ -3,10 +3,10 @@
 
 PREFIX=/c/Program\ Files/Common\ Files/GTK/2.0
 LOADER_DIR=$(PREFIX)/lib/gtk-2.0/2.10.0/loaders
-CFLAGS=-I$(PREFIX)/include/glib-2.0 -I$(PREFIX)/include/gtk-2.0 -I$(PREFIX)/include/pango-1.0 -I$(PREFIX)/lib/glib-2.0/include
+CFLAGS=-Wall -I$(PREFIX)/include/glib-2.0 -I$(PREFIX)/include/gtk-2.0 -I$(PREFIX)/include/pango-1.0 -I$(PREFIX)/lib/glib-2.0/include
 LDFLAGS=-L$(PREFIX)/lib/
 
-all: libpixbufloader-gdip-bmp.dll libpixbufloader-gdip-gif.dll libpixbufloader-gdip-jpeg.dll libpixbufloader-gdip-png.dll libpixbufloader-gdip-tiff.dll libpixbufloader-gdip.dll 
+all: libpixbufloader-gdip-bmp.dll libpixbufloader-gdip-gif.dll libpixbufloader-gdip-jpeg.dll libpixbufloader-gdip-png.dll libpixbufloader-gdip-tiff.dll libpixbufloader-gdip-ico.dll libpixbufloader-gdip-wmf.dll libpixbufloader-gdip-emf.dll 
 
 clean:
 	rm -f *.dll *.o *.exe *~
@@ -17,8 +17,16 @@
 	$(CC) -Wall -O0 -g $(CFLAGS) $(LDFLAGS) test-save.c -o test-save.exe -lole32 -lglib-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0
 	$(CP) test-save.exe $(PREFIX)/bin
 
-libpixbufloader-gdip.dll: io-gdip-native.h  io-gdip-utils.c  io-gdip-utils.h  io-gdip.c  io-gdip-animation.c  io-gdip-animation.h  Makefile.test
-	$(CC) -Wall -O0 -g -shared io-gdip-utils.c io-gdip.c io-gdip-animation.c $(CFLAGS) $(LDFLAGS) -lole32 -lglib-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 -o $@
+libpixbufloader-gdip-ico.dll: io-gdip-native.h  io-gdip-utils.c  io-gdip-utils.h  io-gdip-ico.c  io-gdip-animation.c  io-gdip-animation.h  Makefile.test
+	$(CC) -Wall -O0 -g -shared io-gdip-utils.c io-gdip-ico.c io-gdip-animation.c $(CFLAGS) $(LDFLAGS) -lole32 -lglib-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 -o $@
+	$(CP) $@ $(LOADER_DIR)
+
+libpixbufloader-gdip-wmf.dll: io-gdip-native.h  io-gdip-utils.c  io-gdip-utils.h  io-gdip-wmf.c  io-gdip-animation.c  io-gdip-animation.h  Makefile.test
+	$(CC) -Wall -O0 -g -shared io-gdip-utils.c io-gdip-wmf.c io-gdip-animation.c $(CFLAGS) $(LDFLAGS) -lole32 -lglib-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 -o $@
+	$(CP) $@ $(LOADER_DIR)
+
+libpixbufloader-gdip-emf.dll: io-gdip-native.h  io-gdip-utils.c  io-gdip-utils.h  io-gdip-emf.c  io-gdip-animation.c  io-gdip-animation.h  Makefile.test
+	$(CC) -Wall -O0 -g -shared io-gdip-utils.c io-gdip-emf.c io-gdip-animation.c $(CFLAGS) $(LDFLAGS) -lole32 -lglib-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 -o $@
 	$(CP) $@ $(LOADER_DIR)
 
 libpixbufloader-gdip-bmp.dll: io-gdip-native.h  io-gdip-utils.c  io-gdip-utils.h  io-gdip-bmp.c  io-gdip-animation.c  io-gdip-animation.h  Makefile.test

Added: trunk/src/io-gdip-emf.c
==============================================================================
--- (empty file)
+++ trunk/src/io-gdip-emf.c	Sat Mar 15 15:39:40 2008
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
+ *
+ * Copyright (C) 2008 Dominic Lachowicz
+ * Copyright (C) 2008 Alberto Ruiz
+ *
+ * Authors: Dominic Lachowicz <domlachowicz gmail com>
+ *          Alberto Ruiz <aruiz gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more  * You should have received a copy of the GNU Lesser 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 "io-gdip-utils.h"
+
+void
+MODULE_ENTRY (gdi, fill_vtable) (GdkPixbufModule *module)
+{
+  gdip_fill_vector_vtable (module);
+}
+
+void
+MODULE_ENTRY (gdi, fill_info) (GdkPixbufFormat *info)
+{
+  static GdkPixbufModulePattern signature[] = {
+    { "\x01\x00\x09\x00", NULL, 100 }, /* WMF */
+    { "\x01\x00\x00\x00", NULL, 100 }, /* EMF */
+    { NULL, NULL, 0 }
+  };
+
+  static gchar *mime_types[] = {
+    "application/emf",
+    "application/x-emf",
+    "image/x-emf",
+    "image/x-mgx-emf",
+    NULL
+  };
+
+  static gchar *extensions[] = {
+    "emf",
+    NULL
+  };
+
+  info->name        = "emf";
+  info->signature   = signature;
+  info->description = _("The EMF image format");
+  info->mime_types  = mime_types;
+  info->extensions  = extensions;
+  info->flags       = GDK_PIXBUF_FORMAT_THREADSAFE;
+  info->license     = "LGPL";
+}

Added: trunk/src/io-gdip-ico.c
==============================================================================
--- (empty file)
+++ trunk/src/io-gdip-ico.c	Sat Mar 15 15:39:40 2008
@@ -0,0 +1,60 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
+ *
+ * Copyright (C) 2008 Dominic Lachowicz
+ * Copyright (C) 2008 Alberto Ruiz
+ *
+ * Authors: Dominic Lachowicz <domlachowicz gmail com>
+ *          Alberto Ruiz <aruiz gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more  * You should have received a copy of the GNU Lesser 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 "io-gdip-utils.h"
+
+void
+MODULE_ENTRY (gdi, fill_vtable) (GdkPixbufModule *module)
+{
+  gdip_fill_vtable (module);
+}
+
+void
+MODULE_ENTRY (gdi, fill_info) (GdkPixbufFormat *info)
+{
+  static GdkPixbufModulePattern signature[] = {
+    { "  \x1   ", "zz znz", 100 }, /* ICO */
+    { "  \x2   ", "zz znz", 100 }, /* ICO */
+    { NULL, NULL, 0 }
+  };
+
+  static gchar *mime_types[] = {
+    "image/x-icon",
+    "image/x-ico",
+    NULL
+  };
+
+  static gchar *extensions[] = {
+    "ico",
+    "cur",
+    NULL
+  };
+
+  info->name        = "ico";
+  info->signature   = signature;
+  info->description = _("The ICO image format");
+  info->mime_types  = mime_types;
+  info->extensions  = extensions;
+  info->flags       = GDK_PIXBUF_FORMAT_THREADSAFE;
+  info->license     = "LGPL";
+}

Modified: trunk/src/io-gdip-native.h
==============================================================================
--- trunk/src/io-gdip-native.h	(original)
+++ trunk/src/io-gdip-native.h	Sat Mar 15 15:39:40 2008
@@ -134,6 +134,7 @@
 
 typedef struct _GpImage GpImage;
 typedef struct _GpBitmap GpBitmap;
+typedef struct _GpGraphics GpGraphics;
 
 struct _GdiplusStartupInput
 {
@@ -221,4 +222,14 @@
 typedef GpStatus (WINGDIAPI* GetImageEncodersSizeFunc) (UINT *numEncoders, UINT *size);
 typedef GpStatus (WINGDIPAPI* GdipBitmapSetPixelFunc) (GpBitmap* bitmap, INT x, INT y, ARGB color);
 
+typedef GpStatus (WINGDIPAPI* GdipDrawImageIFunc) (GpGraphics *graphics, GpImage *image, INT x, INT y);
+typedef GpStatus (WINGDIPAPI* GdipGetImageGraphicsContextFunc) (GpImage *image, GpGraphics **graphics);
+typedef GpStatus (WINGDIPAPI* GdipFlushFunc) (GpGraphics *graphics, INT intention);
+typedef GpStatus (WINGDIPAPI* GdipGraphicsClearFunc) (GpGraphics *graphics, ARGB color);
+typedef GpStatus (WINGDIPAPI* GdipBitmapSetResolutionFunc) (GpBitmap* bitmap, float xdpi, float ydpi);
+typedef GpStatus (WINGDIPAPI* GdipGetImageHorizontalResolutionFunc) (GpImage *image, float *resolution);
+typedef GpStatus (WINGDIPAPI* GdipGetImageVerticalResolutionFunc) (GpImage *image, float *resolution);
+typedef GpStatus (WINGDIPAPI* GdipLoadImageFromStreamFunc) (IStream* stream, GpImage **image);
+typedef GpStatus (WINGDIPAPI* GdipDeleteGraphicsFunc) (GpGraphics *graphics);
+
 #endif

Modified: trunk/src/io-gdip-utils.c
==============================================================================
--- trunk/src/io-gdip-utils.c	(original)
+++ trunk/src/io-gdip-utils.c	Sat Mar 15 15:39:40 2008
@@ -47,6 +47,15 @@
 static GdipCreateBitmapFromScan0Func GdipCreateBitmapFromScan0;
 static GdipSaveImageToStreamFunc GdipSaveImageToStream;
 static GdipBitmapSetPixelFunc GdipBitmapSetPixel;
+static GdipDrawImageIFunc GdipDrawImageI;
+static GdipGetImageGraphicsContextFunc GdipGetImageGraphicsContext;
+static GdipFlushFunc GdipFlush;
+static GdipGraphicsClearFunc GdipGraphicsClear;
+static GdipBitmapSetResolutionFunc GdipBitmapSetResolution;
+static GdipGetImageHorizontalResolutionFunc GdipGetImageHorizontalResolution;
+static GdipGetImageVerticalResolutionFunc GdipGetImageVerticalResolution;
+static GdipLoadImageFromStreamFunc GdipLoadImageFromStream;
+static GdipDeleteGraphicsFunc GdipDeleteGraphics;
 
 /* apparently these don't exist until GDI+ 1.1 or later */
 static GetImageEncodersFunc GetImageEncoders;
@@ -95,11 +104,56 @@
   msg = gdip_hresult_to_utf8 (hr);
   
   if (msg) {
-    gdip_propegate_error(err, msg, code);   
+    gdip_propegate_error (err, msg, code);
     g_free (msg);
   }
 }
 
+static void
+_gdip_status_to_gerror (int status, const char *strstatus, gint code, GError **err)
+{
+  gchar *msg;
+
+  msg = g_strdup_printf ("%s (%d)", strstatus, status);
+  gdip_propegate_error (err, msg, code);
+  g_free (msg);
+}
+
+static void
+gdip_status_to_gerror (int status, gint code, GError **err)
+{
+#define CASE(x) case x: _gdip_status_to_gerror (status, #x, code, err); break;
+
+  switch (status)
+    {
+    CASE(GenericError)
+    CASE(InvalidParameter)
+    CASE(OutOfMemory)
+    CASE(ObjectBusy)
+    CASE(InsufficientBuffer)
+    CASE(NotImplemented)
+    CASE(Win32Error)
+    CASE(WrongState)
+    CASE(Aborted)
+    CASE(FileNotFound)
+    CASE(ValueOverflow)
+    CASE(AccessDenied)
+    CASE(UnknownImageFormat)
+    CASE(FontFamilyNotFound)
+    CASE(FontStyleNotFound)
+    CASE(NotTrueTypeFont)
+    CASE(UnsupportedGdiplusVersion)
+    CASE(GdiplusNotInitialized)
+    CASE(PropertyNotFound)
+    CASE(PropertyNotSupported)
+    CASE(ProfileNotFound)
+    default:
+      break;
+    }
+
+#undef CASE
+}
+
 static gboolean
 gdip_init (void)
 {
@@ -145,6 +199,16 @@
   LOOKUP (GdipCreateBitmapFromScan0);
   LOOKUP (GdipSaveImageToStream);
   LOOKUP (GdipBitmapSetPixel);
+  LOOKUP (GdipDrawImageI);
+  LOOKUP (GdipGetImageGraphicsContext);
+  LOOKUP (GdipFlush);
+  LOOKUP (GdipGraphicsClear);
+  LOOKUP (GdipBitmapSetResolution);
+  LOOKUP (GdipGetImageHorizontalResolution);
+  LOOKUP (GdipGetImageVerticalResolution);
+  LOOKUP (GdipLoadImageFromStream);
+  LOOKUP (GdipDeleteGraphics);
+
   TRY_LOOKUP (GetImageEncoders);
   TRY_LOOKUP (GetImageEncodersSize);
 
@@ -302,7 +366,7 @@
 
   if (n_channels == 3 || n_channels == 4) {
     /* rgbX. need to convert to argb. pass a null data to get an empty bitmap */
-    GdipCreateBitmapFromScan0 (width, height, stride, PixelFormat32bppARGB, NULL, &bitmap);
+    GdipCreateBitmapFromScan0 (width, height, 0, PixelFormat32bppARGB, NULL, &bitmap);
     
     if (bitmap) {
       int x, y;
@@ -364,12 +428,46 @@
   
   status = GdipCreateBitmapFromStream (stream, &bitmap);
 
+  gdip_status_to_gerror (status, GDK_PIXBUF_ERROR_FAILED, error);
+
   IStream_Release (stream);
   GlobalFree (hg);
 
   return bitmap;
 }
 
+static GpImage *
+gdip_buffer_to_image (const gchar *buffer, size_t size, GError **error)
+{
+  HRESULT hr;
+  HGLOBAL hg = NULL;
+  GpImage *image = NULL;
+  IStream *stream = NULL;
+  int status;
+
+  hg = gdip_buffer_to_hglobal (buffer, size);
+
+  if (!hg)
+    return NULL;
+
+  hr = CreateStreamOnHGlobal (hg, FALSE, (LPSTREAM *)&stream);
+
+  if (!SUCCEEDED (hr)) {
+    gdip_hresult_to_gerror (hr, GDK_PIXBUF_ERROR_FAILED, error);
+    GlobalFree (hg);
+    return NULL;
+  }
+  
+  status = GdipLoadImageFromStream (stream, &image);
+
+  gdip_status_to_gerror (status, GDK_PIXBUF_ERROR_FAILED, error);
+
+  IStream_Release (stream);
+  GlobalFree (hg);
+
+  return image;
+}
+
 static void
 gdip_bitmap_get_size (GpBitmap *bitmap, guint *width, guint *height)
 {
@@ -694,31 +792,11 @@
 }
 
 static gboolean
-gdk_pixbuf__gdip_image_stop_load (gpointer data, GError **error)
+stop_load (GpBitmap *bitmap, GdipContext *context, GError **error)
 {
-  GdipContext *context = (GdipContext *)data;
-  GpBitmap    *bitmap = NULL;
-  
-  GByteArray *image_buffer = context->buffer;
-  guint8     *tmp_buffer = NULL;
-  guint       buffer_len = 0;
   guint       n_frames = 1, i;
   GdkPixbufGdipAnim *animation = NULL;
 
-  if (error)
-    *error = NULL;
-
-  buffer_len = image_buffer->len;
-  tmp_buffer = image_buffer->data;
-
-  bitmap = gdip_buffer_to_bitmap ((gchar *)image_buffer->data, image_buffer->len, error);
-
-  if (!bitmap) {
-    destroy_gdipcontext (context);
-    gdip_propegate_error (error, _("Couldn't load bitmap"), GDK_PIXBUF_ERROR_CORRUPT_IMAGE);
-    return FALSE;
-  }
-
   gdip_bitmap_get_n_frames (bitmap, &n_frames, TRUE);
 
   for (i = 0; i < n_frames; i++) {
@@ -786,6 +864,95 @@
   return TRUE;
 }
 
+static gboolean
+gdk_pixbuf__gdip_image_stop_load (gpointer data, GError **error)
+{
+  GdipContext *context = (GdipContext *)data;
+  GpBitmap    *bitmap = NULL;
+  GByteArray *image_buffer = context->buffer;
+
+  if (error)
+    *error = NULL;
+
+  bitmap = gdip_buffer_to_bitmap ((gchar *)image_buffer->data, image_buffer->len, error);
+
+  if (!bitmap) {
+    destroy_gdipcontext (context);
+    gdip_propegate_error (error, _("Couldn't load bitmap"), GDK_PIXBUF_ERROR_CORRUPT_IMAGE);
+    return FALSE;
+  }
+
+  return stop_load (bitmap, context, error);
+}
+
+static gboolean
+gdk_pixbuf__gdip_image_stop_vector_load (gpointer data, GError **error)
+{
+  GdipContext *context = (GdipContext *)data;
+  GByteArray *image_buffer = context->buffer;
+
+  GpImage *metafile;
+  GpGraphics *graphics;
+  GpBitmap *bitmap;
+  int status;
+  float metafile_xres, metafile_yres;
+  guint width, height;
+
+  if (error)
+    *error = NULL;
+
+  metafile = gdip_buffer_to_image ((gchar *)image_buffer->data, image_buffer->len, error);
+  if (!metafile) {
+    destroy_gdipcontext (context);
+    gdip_propegate_error (error, _("Couldn't load metafile"), GDK_PIXBUF_ERROR_CORRUPT_IMAGE);
+    return FALSE;
+  }
+
+  GdipGetImageWidth (metafile, &width);
+  GdipGetImageHeight (metafile, &height);
+
+  status = GdipCreateBitmapFromScan0 (width, height, 0, PixelFormat32bppARGB, NULL, &bitmap);
+  if (0 != status) {
+    gdip_status_to_gerror (status, GDK_PIXBUF_ERROR_FAILED, error);
+    GdipDisposeImage (metafile);
+    
+    return FALSE;
+  }
+
+  GdipGetImageHorizontalResolution (metafile, &metafile_xres);
+  GdipGetImageVerticalResolution (metafile, &metafile_yres);
+  GdipBitmapSetResolution (bitmap, metafile_xres, metafile_yres);
+
+  status = GdipGetImageGraphicsContext ((GpImage *)bitmap, &graphics);
+  if (0 != status) {
+    gdip_status_to_gerror (status, GDK_PIXBUF_ERROR_FAILED, error);
+    GdipDisposeImage ((GpImage *)bitmap);
+    GdipDisposeImage (metafile);
+    
+    return FALSE;
+  }
+  
+  /* gotta clear the bitmap */
+  GdipGraphicsClear (graphics, 0xffffffff);
+  
+  status = GdipDrawImageI (graphics, metafile, 0, 0);
+  if (0 != status) {
+    gdip_status_to_gerror (status, GDK_PIXBUF_ERROR_FAILED, error);
+    GdipDeleteGraphics (graphics);
+    GdipDisposeImage ((GpImage *)bitmap);
+    GdipDisposeImage (metafile);
+    
+    return FALSE;
+  }
+  
+  GdipFlush (graphics, 1);
+  
+  GdipDeleteGraphics (graphics);
+  GdipDisposeImage (metafile);
+
+  return stop_load (bitmap, context, error);
+}
+
 static void 
 gdip_animation_prepare (GdkPixbuf *pixbuf,
                         GdkPixbufAnimation *animation,
@@ -875,6 +1042,16 @@
   }
 }
 
+void
+gdip_fill_vector_vtable (GdkPixbufModule *module)
+{
+  if (gdip_init ()) {
+    module->begin_load     = gdk_pixbuf__gdip_image_begin_load;
+    module->stop_load      = gdk_pixbuf__gdip_image_stop_vector_load;
+    module->load_increment = gdk_pixbuf__gdip_image_load_increment;
+  }
+}
+
 gboolean
 gdip_save_pixbuf (GdkPixbuf *pixbuf,
                   const WCHAR *format,

Modified: trunk/src/io-gdip-utils.h
==============================================================================
--- trunk/src/io-gdip-utils.h	(original)
+++ trunk/src/io-gdip-utils.h	Sat Mar 15 15:39:40 2008
@@ -50,6 +50,9 @@
 void
 gdip_fill_vtable (GdkPixbufModule *module);
 
+void
+gdip_fill_vector_vtable (GdkPixbufModule *module);
+
 gboolean
 gdip_save_pixbuf (GdkPixbuf *pixbuf,
                   const WCHAR *format,

Added: trunk/src/io-gdip-wmf.c
==============================================================================
--- (empty file)
+++ trunk/src/io-gdip-wmf.c	Sat Mar 15 15:39:40 2008
@@ -0,0 +1,58 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
+ *
+ * Copyright (C) 2008 Dominic Lachowicz
+ * Copyright (C) 2008 Alberto Ruiz
+ *
+ * Authors: Dominic Lachowicz <domlachowicz gmail com>
+ *          Alberto Ruiz <aruiz gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more  * You should have received a copy of the GNU Lesser 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 "io-gdip-utils.h"
+
+void
+MODULE_ENTRY (gdi, fill_vtable) (GdkPixbufModule *module)
+{
+  gdip_fill_vector_vtable (module);
+}
+
+void
+MODULE_ENTRY (gdi, fill_info) (GdkPixbufFormat *info)
+{
+  static GdkPixbufModulePattern signature[] = {
+    { "\xd7\xcd\xc6\x9a", NULL, 100 }, /* WMF */
+    { NULL, NULL, 0 }
+  };
+
+  static gchar *mime_types[] = {
+    "image/x-wmf",
+    NULL
+  };
+
+  static gchar *extensions[] = {
+    "wmf",
+    "apm",
+    NULL
+  };
+
+  info->name        = "wmf";
+  info->signature   = signature;
+  info->description = _("The WMF image format");
+  info->mime_types  = mime_types;
+  info->extensions  = extensions;
+  info->flags       = GDK_PIXBUF_FORMAT_THREADSAFE;
+  info->license     = "LGPL";
+}



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