Saving a BMP file with 16 bit pixel resolution (5:6:5)

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Posts: 4
Joined: 2018-01-08T07:25:30-07:00
Authentication code: 1152

Saving a BMP file with 16 bit pixel resolution (5:6:5)

Post by mch » 2018-01-10T03:05:49-07:00

I have been told that IM cannot save a BMP file with a 16 bit pixel resolution ie each pixel is represented by 2 bytes with RGB stored as 5:6:5. It can however read files with this format.

See link to the thread discussing this.
viewtopic.php?f=1&t=33334&sid=6ceff1fda ... 1a38826f62

I would like to suggest a modification to IM that would support this format, obviously colour depth may possibly be lost as the most LSB's of the colour info would have to be dropped. In my case as these bits never existed as the files started out as 5:6:5 its not a problem. The reason that this is important to me is that I am using a lot of graphics files in a small embedded application and image size is very important to me.

Here is a link to a .BMP file I am using that is stored with a 16 bit pixel size. ... 2.BMP?dl=0

Regards, Martin

User avatar
Posts: 1411
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789

Re: Saving a BMP file with 16 bit pixel resolution (5:6:5)

Post by dlemstra » 2018-01-11T15:23:35-07:00

Maybe you should read your topic again?
.NET + ImageMagick = Magick.NET, @MagickNET, Donate

User avatar
Posts: 22427
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Saving a BMP file with 16 bit pixel resolution (5:6:5)

Post by fmw42 » 2018-01-11T15:47:35-07:00

The file you posted is 24bits. BMP3 does not support the 5:6:5 format, since it does not have fields in the header to identify it as such. Whereas, BMP (BMP4) does contain such headers. If you have an example BMP3 file in 5:6:5 format, post that so the developers can see how it can be identified as such.

Jason S
Posts: 89
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

Re: Saving a BMP file with 16 bit pixel resolution (5:6:5)

Post by Jason S » 2018-01-12T08:25:30-07:00

I could not figure out how to download mch's example file with a web browser. What I ended up with was always either a JPEG or HTML file. I was able to download it with wget. It is BMPv3 16-bit RGB555, not RGB565.

BMPv3 supports 16-bit images with arbitrary RGB (though not RGBA) color formats. You just have to write an extra "BITFIELDS" segment after the header, for any format other than RGB555. ImageMagick can read such images, but can't write them.

If IM were to support writing BMPv3 RGB565, it ought to support RGB555 as well, since it also has the "bmp:subtype=RGB555" option.

Even if it does not support these things, I'd say it should ignore the options completely, instead of producing malformed files as it does now.

Format reference

RGB555 without BITFIELDS

Post Reply