Page 1 of 1

is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-20T04:06:39-07:00
by Nezar
I read that it is impossible, but it can all still have some way either.
And then I had two days writing a program, but only now noticed that the obtained bmp files with alpha channel can not be read, because they have a version 1.
A need - 3
Help, please!

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-20T09:02:22-07:00
by Drarakel
BMP Version 1 - with alpha channel?? Can't believe that.
I'm not sure what your question is. As I said, with a current version of ImageMagick, you can read/write BMP V4 and V5 files with an alpha layer (not BMP3).

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-20T19:24:00-07:00
by el_supremo
BMP3 doesn't support an alpha channel.

Pete

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-21T05:53:02-07:00
by Nezar
when I do so
convert 1.png 1.bmp
I get a bmp file with alpha channel v1
if I open this file in Potoshop and resave in the bmp, I get a bmp file with alpha channel ver 3

If you do so
convert 1.png BMP3: 1.bmp
I get a bmp file without an alpha channel v3

This information gives FastStone

Версия ImageMagick 6.6.1-Q16-windows

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-21T10:05:55-07:00
by el_supremo
when I do so
convert 1.png 1.bmp
I get a bmp file with alpha channel v1
What do you mean it is V1? The V1 BMP format doesn't support an alpha layer.
if I open this file in Potoshop and resave in the bmp, I get a bmp file with alpha channel ver 3
V3 does not support an alpha layer. How do you know it is V3?
If you do so
convert 1.png BMP3: 1.bmp
I get a bmp file without an alpha channel v3
That's correct because V3 does not support an alpha layer.

I converted a PNG (with alpha) to BMP with the simple command:

Code: Select all

convert input.png output.bmp
The resulting BMP file has a 1-bit alpha layer and is BMP4 format because the size of the header is 108 bytes.

The only sure way to tell which version of BMP you are getting is to look at the BMP file with a hex editor and look at bytes 14 and 15 which specify the size of the header file.
If it is 40 (decimal) then it is BMP3.
If it is 108 (decimal) then it is BMP4.
Anything larger than 108 is BMP5 and anything smaller than 40 is a very early version of BMP that you're unlikely to come across any more.

Pete

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-21T11:27:00-07:00
by Drarakel
el_supremo wrote:That's correct because V3 does not support an alpha layer.
In ImageMagick, it's not supported. But a few other programs do create BMP V3 files with alpha layer.
Nezar wrote:when I do so
convert 1.png 1.bmp
I get a bmp file with alpha channel v1
Most likely, you will get a BMP V4 file.
Again: BMP3 with alpha channel, that's not possible in ImageMagick at the moment. If you edit the files with another program, you should save again to PNG for example.

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-21T11:48:34-07:00
by el_supremo
But a few other programs do create BMP V3 files with alpha layer
Microsoft's description of the BMP3 header format does not include any allowance for an alpha layer.
If you have a BMP3 file with alpha layer I'd appreciate it if you could post a link to it so that I can look at the header.

Pete

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-21T12:46:41-07:00
by Drarakel
You're probably referring to the line "The high byte in each DWORD is not used." within the biBitCount section. But that line is the same in the BITMAPV4HEADER and BITMAPV5HEADER descriptions. I just don't think much of these details within the Microsoft descriptions - it's not really consistent there. But I'm not an expert of BMP headers..
Anyway, this gets off-topic. (I'll probably start a thread in the developers forum sometime - as I always thought that ImageMagick should at least read the BMP V3 +alpha channel files.)

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-24T23:59:17-07:00
by Nezar
Thank you for your answers.
To solve the problem - I found the console program nconvert.
And with the help of her overtake BMP to PNG and vice versa with the persistence transparency necessary and alpha layer.
Unfortunately I do not know how to lay out here its BMP files that you can see them.
Try this program and look at the resulting BMP / And if not difficult - who know, tell me what version of it.

Thanks again.

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-25T09:23:20-07:00
by el_supremo
nconvert doesn't work for me. I tried converting a transparent PNG to BMP with this command:

Code: Select all

nconvert.exe -out bmp -o %_nc.bmp eqn9_trans_040.png
nconvert printed:

Code: Select all

Conversion of eqn9_trans_040.png into eqn9_trans_040_nc.bmp OK
But the BMP file just has a black background.
It might be the program that I am using to display the image. I've used PSPX and PSPX3 which show that the PNG is transparent but the BMP is not.
Which program are you using to display the image or to demonstrate that the BMP has an alpha channel?

Pete

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-28T12:25:09-07:00
by Drarakel
Nconvert creates ARGB files with a BMP V3 header.

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-28T15:11:45-07:00
by fmw42
el_supremo wrote: Which program are you using to display the image or to demonstrate that the BMP has an alpha channel?

Pete,

Try downloading irfanview and see if that is a better display program. Other windows users have found it better than the Windows tools. I hear good things about it, but as I am a Mac user, it does me no good as it is windows only.

http://www.irfanview.com/

Fred

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-28T18:34:15-07:00
by Drarakel
IrfanView is indeed a good programm - but it can't display transparency.
Free Windows software that is able to handle the alpha channel in BMP V3 files is Gimp or XnView (the latter includes Nconvert).

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-28T20:42:58-07:00
by el_supremo
I've installed Xnview and it does indicate that a BMP3 file that I created with nconvert has transparency. So, I looked at a hexdump of the file.
The BMP3 file header indicates that the image has 32-bits per pixel. Nconvert has used the high byte of each DWORD to indicate the opacity of the pixel. If it is zero, the pixel is transparent and if it is 255 the pixel is fully opaque. I haven't tried to sort out whether Nconvert will produce a BMP3 with partially transparent pixels nor whether Xnview could display one properly.
However, BMP is a Microsoft file format and the documentation that comes with my C compiler, and also what I have found on Microsoft's website, says that the high byte of each DWORD is unused. Therefore using this byte for opacity (or anything else) is a non-standard use.
The specific problem that I can see right now is that because Microsoft says that the high byte is unused, programs are free to leave any random value in that byte. How do you then distinguish between a BMP generated by such a program and a BMP which is using that byte as opacity?
I don't think that Magick (IM's developer) will expend any effort on the BMP coder to handle an apparently undefined/undocumented extension of the BMP format. If you can find documentation of this extension and how it fits in with the existing BMP3 spec maybe it will happen.

Pete

Re: is it possible to create a BMP3 with alpha channel?

Posted: 2010-05-28T21:19:58-07:00
by Drarakel
el_supremo wrote:whether Nconvert will produce a BMP3 with partially transparent pixels nor whether Xnview could display one properly.
Yes (both cases).
el_supremo wrote:However, BMP is a Microsoft file format and the documentation that comes with my C compiler, and also what I have found on Microsoft's website, says that the high byte of each DWORD is unused. Therefore using this byte for opacity (or anything else) is a non-standard use.
As I said, the Microsoft documentation for BITMAPV4HEADER and BITMAPV5HEADER says the exact same thing ("The high byte in each DWORD is not used."). So, ImageMagick already supports a non-standard format by reading/writing BMP V4 and V5 files with transparency. :wink: (Does your compiler documentation differ from the bitmap header documentation that is available online?)
But let's leave it as that for now.. (Even for me, the support for BMP V3 files with transparency is not the top priority.)