cannot generate 32bit BMP files using ARGB format

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.

Re: cannot generate 32bit BMP files using ARGB format

Postby sorin » 2009-05-01T00:24:25+00:00

I don't really know all the internals of BMP file format but if you are telling that what Gimps saves is an BMP3 all we have do to is to improve a little bit the export-to-BMP3 from ImageMagick.

I wasn't able to find *any* program that would fail to load the GIMP BMP/ARGB format and there are 5 cases where the alpha channel is loaded: Windows API , Gimp, Photoshop, Safari and Chrome.

Anyway, I managed to get away from BMP by switching to PNG+some lines of code. But, I would like to continue work with you on solving this because ImageMagick is a great product and I want to improve it.

Thanks,
sorin
 

Re: cannot generate 32bit BMP files using ARGB format

Postby magick » 2009-05-01T09:18:19+00:00

Looks like a simple patch to ImageMagick could resolve the problem. Since BMP3 permits an alpha channel we need to enhance ImageMagick to save as BMP3 when you use a filename like this: bmp3:image.bmp. Currently we automatically save as BMP version 4 if the image has an alpha channel.
User avatar
magick
Site Admin
 
Posts: 9670
Joined: 2003-05-31T11:32:55+00:00

Re: cannot generate 32bit BMP files using ARGB format

Postby mfulton » 2009-07-19T16:57:55+00:00

I've read messages here that referred to the fileformat.info website as a source of information on the BMP format. Please be aware that the information on BMP given at that site is various times either misleading or just plain wrong, not to mention being drastically overcomplicated. It's not surprising that someone would be confused if they were relying on that site. The original book it's based on came out in 1994, and the 2nd edition in early 1996, so it's likely this information was based on beta code and/or documentation, or just plain guesswork.

The biggest problem is the fact that their definition of the "BMP Version 3 (Windows NT)" and "BMP Version 4" formats, including especially the definition of the WINNTBITMAPHEADER and WIN4XBITMAPHEADER structures, seems to be a bastardized reference to Microsoft's BITMAPV4HEADER and BITMAPV5HEADER structures, and is simply not correct.

Any application that creates BMP files based on the WIN4XBITMAPHEADER and WINNTBITMAPHEADER structures defined on the fileformat.info website, or the original book, is not creating VALID files.

By "valid" I mean in keeping with Microsoft's documentation. Note that "invalid" BMP files will still work perfectly fine in many applications, if not MOST, regardless of the platform, if the only problem is a non-standard header. As long as the first 40 bytes that match the BITMAPINFOHEADER structure are used properly, most applications will simply ignore the extra fields. Even those applications which DO support the extra information in the BITMAPV4HEADER and BITMAPV5HEADER structures should work as long as they're properly checking the size field in the header.

For maximum compatibility, applications creating BMP files should use the 40-byte BITMAPINFOHEADER structure. The BITMAPV4HEADER and BITMAPV5HEADER structures are VERY RARELY used, and rarely properly. Anybody writing code to create BMP files should probably avoid using them if at all possible. In fact, from what I can see, using them seems to be the #1 cause of problems with BMP files created on non-Windows platforms.

Microsoft's definition of the .BMP format is given at: http://msdn.microsoft.com/en-us/library/dd183391(VS.85).aspx
mfulton
 

Re: cannot generate 32bit BMP files using ARGB format

Postby magick » 2009-07-19T17:28:54+00:00

ImageMagick conforms to the Microsoft definition of the BMP image format. We support both the BITMAPV4HEADER defined here: http://msdn.microsoft.com/en-us/library ... 85%29.aspx and BITMAPV5HEADER defined here: http://msdn.microsoft.com/en-us/library ... 85%29.aspx.

If ImageMagick produces an image that does meet the Microsoft BMP specification we consider that a bug and will fix it if its properly documented as a bug to this list. If another program fails to read BMP images produced by ImageMagick you can force the more popular BITMAPV4HEADER with this command:

    convert image.jpg bmp3:image.bmp
User avatar
magick
Site Admin
 
Posts: 9670
Joined: 2003-05-31T11:32:55+00:00

Re: cannot generate 32bit BMP files using ARGB format

Postby Tobias78 » 2010-01-29T03:44:18+00:00

I need a 32Bit Bitmap included Alpha Channel which gimp can read. If the format I need is incompatible with MS specifications, I couldn't care less, since other programs and algorithm's I use need this Foramt too!

What a shame! ImageMagic should be able to produce this format anyhow.
"convert -alpha on pic.png bmp3:pic.bmp" doesn't work anyway, the alpha channel is missing.

But fortunately I found a alternative to convert png's bmp's with the alpha channel in the format I need (and Gimp can read):
( http://www.miichsoft.com/software/imageconverter/ )

>If another program fails to read BMP images produced by ImageMagick you can force the more popular BITMAPV4HEADER with this command:
> convert image.jpg bmp3:image.bmp
Tobias78
 

Re: cannot generate 32bit BMP files using ARGB format

Postby fmw42 » 2010-01-29T10:36:28+00:00

try

convert pic.png -channel rgba -alpha on bmp3:pic.bmp

or on older IM versions

convert pic.png -channel rgba -matte bmp3:pic.bmp
User avatar
fmw42
 
Posts: 14946
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: cannot generate 32bit BMP files using ARGB format

Postby Tobias78 » 2010-01-30T08:10:03+00:00

It's the same, no difference. ( Image Magic 6.5.9 Q16)

>convert pic.png -channel rgba -alpha on bmp3:pic.bmp
Tobias78
 

Previous

Return to Bugs

Who is online

Users browsing this forum: Google Adsense [Bot], Majestic-12 [Bot] and 7 guests