[gimp/gimp-2-8] file-bmp: Reject compression type BI_ALPHABITFIELDS as unsupported
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] file-bmp: Reject compression type BI_ALPHABITFIELDS as unsupported
- Date: Mon, 8 Oct 2012 03:48:30 +0000 (UTC)
commit 49debcafdc38e8b14e4a8ca890cfe193fdf1fa99
Author: Mukund Sivaraman <muks banu com>
Date: Mon Oct 8 08:47:17 2012 +0530
file-bmp: Reject compression type BI_ALPHABITFIELDS as unsupported
These were erroneously parsed before. Now we reject them. It is
trivial to implement support for them, but we can't test it unless
someone comes up with a sample BMP file. They don't seem to be
available in the wild.
plug-ins/file-bmp/bmp-read.c | 115 +++++++++++++++++++++++-------------------
1 files changed, 63 insertions(+), 52 deletions(-)
---
diff --git a/plug-ins/file-bmp/bmp-read.c b/plug-ins/file-bmp/bmp-read.c
index 78e2cbf..48888ff 100644
--- a/plug-ins/file-bmp/bmp-read.c
+++ b/plug-ins/file-bmp/bmp-read.c
@@ -35,10 +35,11 @@
#if !defined(WIN32) || defined(__MINGW32__)
-#define BI_RGB 0
-#define BI_RLE8 1
-#define BI_RLE4 2
-#define BI_BITFIELDS 3
+#define BI_RGB 0
+#define BI_RLE8 1
+#define BI_RLE4 2
+#define BI_BITFIELDS 3
+#define BI_ALPHABITFIELDS 4
#endif
static gint32 ReadImage (FILE *fd,
@@ -285,56 +286,66 @@ ReadBMP (const gchar *name,
Bitmap_Head.masks[0] = ToL(&buffer[0x00]);
Bitmap_Head.masks[1] = ToL(&buffer[0x04]);
Bitmap_Head.masks[2] = ToL(&buffer[0x08]);
- ReadChannelMasks (&Bitmap_Head.masks[0], masks, 3);
+ ReadChannelMasks (&Bitmap_Head.masks[0], masks, 3);
+ }
+ else if (Bitmap_Head.biCompr == BI_RGB)
+ {
+ switch (Bitmap_Head.biBitCnt)
+ {
+ case 32:
+ masks[0].mask = 0x00ff0000;
+ masks[0].shiftin = 16;
+ masks[0].max_value= (gfloat)255.0;
+ masks[1].mask = 0x0000ff00;
+ masks[1].shiftin = 8;
+ masks[1].max_value= (gfloat)255.0;
+ masks[2].mask = 0x000000ff;
+ masks[2].shiftin = 0;
+ masks[2].max_value= (gfloat)255.0;
+ masks[3].mask = 0xff000000;
+ masks[3].shiftin = 24;
+ masks[3].max_value= (gfloat)255.0;
+ break;
+ case 24:
+ masks[0].mask = 0xff0000;
+ masks[0].shiftin = 16;
+ masks[0].max_value= (gfloat)255.0;
+ masks[1].mask = 0x00ff00;
+ masks[1].shiftin = 8;
+ masks[1].max_value= (gfloat)255.0;
+ masks[2].mask = 0x0000ff;
+ masks[2].shiftin = 0;
+ masks[2].max_value= (gfloat)255.0;
+ masks[3].mask = 0x0;
+ masks[3].shiftin = 0;
+ masks[3].max_value= (gfloat)0.0;
+ break;
+ case 16:
+ masks[0].mask = 0x7c00;
+ masks[0].shiftin = 10;
+ masks[0].max_value= (gfloat)31.0;
+ masks[1].mask = 0x03e0;
+ masks[1].shiftin = 5;
+ masks[1].max_value= (gfloat)31.0;
+ masks[2].mask = 0x001f;
+ masks[2].shiftin = 0;
+ masks[2].max_value= (gfloat)31.0;
+ masks[3].mask = 0x0;
+ masks[3].shiftin = 0;
+ masks[3].max_value= (gfloat)0.0;
+ break;
+ default:
+ break;
+ }
}
else
- switch (Bitmap_Head.biBitCnt)
- {
- case 32:
- masks[0].mask = 0x00ff0000;
- masks[0].shiftin = 16;
- masks[0].max_value= (gfloat)255.0;
- masks[1].mask = 0x0000ff00;
- masks[1].shiftin = 8;
- masks[1].max_value= (gfloat)255.0;
- masks[2].mask = 0x000000ff;
- masks[2].shiftin = 0;
- masks[2].max_value= (gfloat)255.0;
- masks[3].mask = 0xff000000;
- masks[3].shiftin = 24;
- masks[3].max_value= (gfloat)255.0;
- break;
- case 24:
- masks[0].mask = 0xff0000;
- masks[0].shiftin = 16;
- masks[0].max_value= (gfloat)255.0;
- masks[1].mask = 0x00ff00;
- masks[1].shiftin = 8;
- masks[1].max_value= (gfloat)255.0;
- masks[2].mask = 0x0000ff;
- masks[2].shiftin = 0;
- masks[2].max_value= (gfloat)255.0;
- masks[3].mask = 0x0;
- masks[3].shiftin = 0;
- masks[3].max_value= (gfloat)0.0;
- break;
- case 16:
- masks[0].mask = 0x7c00;
- masks[0].shiftin = 10;
- masks[0].max_value= (gfloat)31.0;
- masks[1].mask = 0x03e0;
- masks[1].shiftin = 5;
- masks[1].max_value= (gfloat)31.0;
- masks[2].mask = 0x001f;
- masks[2].shiftin = 0;
- masks[2].max_value= (gfloat)31.0;
- masks[3].mask = 0x0;
- masks[3].shiftin = 0;
- masks[3].max_value= (gfloat)0.0;
- break;
- default:
- break;
- }
+ {
+ /* BI_ALPHABITFIELDS, etc. */
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Unsupported compression (%lu) in BMP file from '%s'"),
+ Bitmap_Head.biCompr,
+ gimp_filename_to_utf8 (filename));
+ }
}
else if (Bitmap_File_Head.biSize >= 56 && Bitmap_File_Head.biSize <= 64)
/* enhanced Windows format with bit masks */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]