After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 158033 - Error reading BMP files with negative height!
Error reading BMP files with negative height!
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.0.x
Other All
: Normal normal
: 2.2
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-11-12 11:28 UTC by Andrea Fontana
Modified: 2005-01-14 19:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A bmp with negative height (88.66 KB, application/x-zip-compressed)
2005-01-13 17:22 UTC, Andrea Fontana
Details

Description Andrea Fontana 2004-11-12 11:28:20 UTC
I find out this bug working on my own Bitmap writer.

According to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/gdi/bitmaps_1rw2.asp

"[...] If biHeight is positive, the bitmap is a bottom-up DIB and its origin 
is the lower-left corner. If biHeight is negative, the bitmap is a top-down 
DIB and its origin is the upper-left corner. 
If biHeight is negative, indicating a top-down DIB, biCompression must be 
either BI_RGB or BI_BITFIELDS. Top-down DIBs cannot be compressed. [...]"

If you load a bmp with negative height gimp crashes because bmp plugin or 
libgimp check for height>0 during loading...

I hope this can help you...

Bye,
Andrea Fontana
Comment 1 Sven Neumann 2004-11-12 12:09:34 UTC
Could you attach such a BMP file to this bug report, please.
Comment 2 Sven Neumann 2005-01-13 15:11:00 UTC
We are still waiting for an example file to be attached here.
Comment 3 Andrea Fontana 2005-01-13 17:22:13 UTC
Created attachment 35960 [details]
A bmp with negative height
Comment 4 weskaggs 2005-01-13 18:39:58 UTC
re-opening because reporter has responded with requested info
Comment 5 weskaggs 2005-01-13 21:35:27 UTC
The attached file is actually a zip file, which unzips to create a file called
Test.bmp.  (It took me about an hour to figure this out.)
Comment 6 Sven Neumann 2005-01-13 21:48:27 UTC
'file' is your friend
Comment 7 Andrea Fontana 2005-01-13 21:52:34 UTC
I'm sorry, i'm a newbie with bugzilla, i'm trying to help community. 
Comment 8 Andrea Fontana 2005-01-13 21:54:17 UTC
Probably i can't use attachments so well :)
Comment 9 weskaggs 2005-01-13 22:02:26 UTC
Okay, fixed in CVS head.

2005-01-13  Bill Skaggs <weskaggs@primate.ucdavis.edu>

	* plug-ins/bmp/bmp.h
	* plug-ins/bmp/bmpread.c: handle negative height values
	as per spec, fixes bug #158033
Comment 10 weskaggs 2005-01-13 22:07:24 UTC
Unfortunately the only way to let people know in Bugzilla that the attachment is
an archive or a compressed file is to add a comment saying so.
Comment 11 Andrea Fontana 2005-01-13 22:17:56 UTC
I hope that if height is negative you handle bmp as topdown bitmap...
Comment 12 Sven Neumann 2005-01-13 23:00:15 UTC
Regarding comment #10: Another way is to specify a proper mime-type for the
attachment, which is excatly what Andrea did.
Comment 13 Sven Neumann 2005-01-13 23:17:31 UTC
This fix should probably be backported to GIMP 2.2. Reopening and setting the
milestone accordingly.
Comment 14 Sven Neumann 2005-01-13 23:22:04 UTC
2005-01-14  Sven Neumann  <sven@gimp.org>

        Merged from HEAD branch (fix by Bill Skaggs):

        * plug-ins/bmp/bmp.h
        * plug-ins/bmp/bmpread.c: handle negative height values
        as per spec, fixes bug #158033
Comment 15 weskaggs 2005-01-14 00:23:23 UTC
I'm not blaming anybody, but just to explain, the unfortunate thing is that in
Bugzilla every attachment is called "attachment.cgi.html", regardless of what it
is, so if I see an attachment described as "A bmp with negative height", it is
natural for me to Save Link Target As... and call the result test.bmp.  I then
try to open the result in GIMP, see it fail as expected, and spend quite some
time trying to pin down the error before realizing that this isn't actually a
bmp file.  But there is no way for you to have realized this would happen, so
there is no blame. 

And yes, the image gets flipped after loading if the height value is negative.
Comment 16 Sven Neumann 2005-01-14 19:02:00 UTC
Bill, I suggest instead of saving, you simply click on the attachment. Bugzilla
will serve it with the proper mime-type then, which should have sent it to
file-roller or whatever archiver is configured in your browser.