[gimp] Bug 586851 – Transparent BMP files fail to load
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp] Bug 586851 – Transparent BMP files fail to load
- Date: Wed, 22 Jul 2009 16:16:03 +0000 (UTC)
commit 61db48ac746e1b609dae3072d7fc0b702f1ff70d
Author: Massimo Valentini <sixtysix inwind it>
Date: Wed Jul 22 18:17:00 2009 +0200
Bug 586851 â?? Transparent BMP files fail to load
If everything else fails, use gdk_pixbuf_new_from_file().
plug-ins/file-bmp/bmp-read.c | 35 +++++++++++++++++++++++++++++++----
1 files changed, 31 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/file-bmp/bmp-read.c b/plug-ins/file-bmp/bmp-read.c
index cb54ea0..804c320 100644
--- a/plug-ins/file-bmp/bmp-read.c
+++ b/plug-ins/file-bmp/bmp-read.c
@@ -26,8 +26,10 @@
#include <string.h>
#include <glib/gstdio.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libgimp/gimp.h>
+#include <libgimp/gimppixbuf.h>
#include "bmp.h"
@@ -366,10 +368,35 @@ ReadBMP (const gchar *name,
}
else
{
- g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
- _("Error reading BMP file header from '%s'"),
- gimp_filename_to_utf8 (filename));
- return -1;
+ GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
+
+ if (pixbuf)
+ {
+ gint32 layer_ID;
+
+ image_ID = gimp_image_new (gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf),
+ GIMP_RGB);
+
+ layer_ID = gimp_layer_new_from_pixbuf (image_ID, _("Background"),
+ pixbuf,
+ 100.,
+ GIMP_NORMAL_MODE, 0, 0);
+ g_object_unref (pixbuf);
+
+ gimp_image_set_filename (image_ID, filename);
+ gimp_image_add_layer (image_ID, layer_ID, -1);
+
+ return image_ID;
+ }
+ else
+ {
+
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Error reading BMP file header from '%s'"),
+ gimp_filename_to_utf8 (filename));
+ return -1;
+ }
}
/* Valid bitpdepthis 1, 4, 8, 16, 24, 32 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]