I've been able to create a Format48bppRgb .PNG file (from some internal HDR data) using the the following C# code:
Bitmap bmp16 = new Bitmap(_viewer.Width, _viewer.Height, System.Drawing.Imaging.PixelFormat.Format48bppRgb);
System.Drawing.Imaging.BitmapData data16 = bmp16.LockBits(_viewer.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly, bmp16.PixelFormat);
unsafe { (populates bmp16) }
bmp16.Save( "C:/temp/48bpp.png", System.Drawing.Imaging.ImageFormat.Png );
ImageMagik (and other apps) verify that this is indeed a 16bpp image:
C:\temp>identify 48bpp.png
48bpp.png PNG 1022x1125 1022x1125+0+0 DirectClass 16-bit 900.963kb
I was disappointed, however, to find that on reading the PNG back in, it had been converted to Format32bppRgb, when using:
Bitmap bmp = new Bitmap( "c:/temp/48bpp.png", false );
String info = String.Format("PixelFormat: {0}", bmp.PixelFormat );
...
Given that the PNG codec can write a Format48bppRgb, is there any way I can use .NET to read it in without the conversion? I don't mind if it does this for a DrawImage call, but I would like access to the decompressed, original data for some histogram/image processing work.