[Mono-list] PixelFormat.Format16bppRgb565

Sebastien Pouliot sebastien.pouliot at gmail.com
Fri Aug 10 13:44:40 EDT 2007

On Fri, 2007-08-10 at 18:10 +0200, Wyborski Marek wrote:
> Hello!
> I have got a problem with Bitmaps and the PixelFormat. I want to save
> a Bitmap with PixelFormat.Format16bppRgb565. If I run Mono on Windows
> it works, but under Linux it is saving the Bitmap with 32Bit Colors.
> Why???

Sadly not every codec supports every feature. The correct handling of
loading 16bbp files is fairly recent itself.

> Example:
> Bitmap bmp = new Bitmap(300, 300, PixelFormat.Format16bppRgb565);
> bmp.Save(“bmp.bmp”, ImageFormat.Bmp);
> With Mono on Windows the File is 180066 bytes large, but on Linux it
> is 360054. So what is the difference in PixelFormat Handling on the
> different platforms? 

It's probably unimplemented and defaults to 32bpp.

Please fill a bug, including a test case, on http://bugzilla.ximian.com

> I would really need the functionality, if there is another way to save
> the bitmap with 16 Bit Colors please let me know. 

You may want to try other codecs (e.g. JPEG or PNG) to see it 16bpp is
supported (I don't recall offhand).

> Saving it as 32Bit and then converting each Color to 16Bit seems to be
> expensive.

This is what will happen anyway since Cairo surfaces don't deal with
every PixelFormat GDI+ supports (so we turn other formats into 24 or

Sebastien Pouliot  <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/

More information about the Mono-list mailing list