diff --git a/ChangeLog b/ChangeLog index 5720d4bba7..6231170336 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-01-13 Bill Skaggs + + * plug-ins/bmp/bmp.h + * plug-ins/bmp/bmpread.c: handle negative height values + as per spec, fixes bug #158033 + 2005-01-13 Michael Natterer Allow to easily open brushes and patterns as images. diff --git a/plug-ins/bmp/bmp.h b/plug-ins/bmp/bmp.h index 7270f3af35..0dc5d39512 100644 --- a/plug-ins/bmp/bmp.h +++ b/plug-ins/bmp/bmp.h @@ -46,7 +46,7 @@ extern struct Bitmap_File_Head_Struct extern struct Bitmap_Head_Struct { gulong biWidth; /* 12 */ - gulong biHeight; /* 16 */ + glong biHeight; /* 16 */ gushort biPlanes; /* 1A */ gushort biBitCnt; /* 1C */ gulong biCompr; /* 1E */ diff --git a/plug-ins/bmp/bmpread.c b/plug-ins/bmp/bmpread.c index e953eadb7d..c711398e8f 100644 --- a/plug-ins/bmp/bmpread.c +++ b/plug-ins/bmp/bmpread.c @@ -103,7 +103,7 @@ ReadChannelMasks (FILE *fd, Bitmap_Channel *masks, guint channels) guint32 tmp[3]; guint32 mask; gint i, nbits, offset, bit; - + if (!ReadOK (fd, tmp, 3 * sizeof (guint32))) return FALSE; @@ -167,8 +167,8 @@ ReadBMP (const gchar *name) !strncmp (magick,"PI",2) || !strncmp (magick,"CI",2) || !strncmp (magick,"CP",2))) { - g_message (_("'%s' is not a valid BMP file"), - gimp_filename_to_utf8 (filename)); + g_message (_("'%s' is not a valid BMP file 0, magick = %c%c"), + gimp_filename_to_utf8 (filename), magick[0], magick[1]); return -1; } @@ -176,13 +176,13 @@ ReadBMP (const gchar *name) { if (!ReadOK (fd, buffer, 12)) { - g_message (_("'%s' is not a valid BMP file"), + g_message (_("'%s' is not a valid BMP file 1"), gimp_filename_to_utf8 (filename)); return -1; } if (!ReadOK (fd, magick, 2)) { - g_message (_("'%s' is not a valid BMP file"), + g_message (_("'%s' is not a valid BMP file 2"), gimp_filename_to_utf8 (filename)); return -1; } @@ -190,7 +190,7 @@ ReadBMP (const gchar *name) if (!ReadOK (fd, buffer, 12)) { - g_message (_("'%s' is not a valid BMP file"), + g_message (_("'%s' is not a valid BMP file 3"), gimp_filename_to_utf8 (filename)); return -1; } @@ -338,7 +338,7 @@ ReadBMP (const gchar *name) masks = g_new (Bitmap_Channel, 3); if (! ReadChannelMasks (fd, masks, 3)) { - g_message (_("'%s' is not a valid BMP file"), + g_message (_("'%s' is not a valid BMP file 4"), gimp_filename_to_utf8 (filename)); return -1; } @@ -374,7 +374,7 @@ ReadBMP (const gchar *name) /* Get the Image and return the ID or -1 on error*/ image_ID = ReadImage (fd, Bitmap_Head.biWidth, - Bitmap_Head.biHeight, + ABS (Bitmap_Head.biHeight), ColorMap, Bitmap_Head.biClrUsed, Bitmap_Head.biBitCnt, @@ -400,6 +400,9 @@ ReadBMP (const gchar *name) gimp_image_set_resolution (image_ID, xresolution, yresolution); } + if (Bitmap_Head.biHeight < 0) + gimp_image_flip (image_ID, GIMP_ORIENTATION_VERTICAL); + return image_ID; }