c# - Reading/preserving a PixelFormat.Format48bppRgb PNG Bitmap in .NET? -


I am able to create the Format48bppRgb .png file (with some internal HDR data) using the following C # code: / P>

  Bitmap BMP16 = New Bitmap (_viewer.Width, _viewer.Height, System.Downings.imaging.pixelformat.format 48bpRGB); System.Drawing.Imaging.BitmapData data16 = bmp16.LockBits (_viewer.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly, bmp16.PixelFormat); Unsafe {(Populated BMP 16)} BMP 16.Save ("C: /temp/48bpp.png", System.Downing.imaging.imageformat.png); ImageMagik (and other apps) verify that this is actually a 16bpp image:  
  C: \ Temp & gt; 48bpp.png 48bpp.png PNG 1022x1125 Identify 1022x1125 + 0 + 0 Direct Class 16-bit 900.963kb   

However, in reading PNG I was frustrated to find out, To change it was changed to Format32bppRgb:

  Bitmap BMP = new bitmap ("c: /temp/48bpp.png", incorrect); String information = string.format ("pixel format: {0}", BMP pixel format); ...   

Given that PNG codec can write a Format 48bppRgb, can I use .NET to read it without conversions? I have no problem that it does for a dormant call, but I want access to some uncomfortable, original data access to some histogram / image processing work.

...

And from this code snippet:

  Private Systems Drawing Bitmap _bitmapFromSource (bitmapsource bitmapsource) {system drawing. Bitmap bitmap; (MemoryStream Outstream = New MemoryStream ()) using System.Drawing.Bitmap Bitmap Encoder Encoder = // System.Media.bitmapImage =) using BmpBitmapEncoder (); Enc.frames.Add (bitmapFrame.Create (bitmapsource)); Enc.Save (outStream); Bitmap = new system Drawing Bitmap (Outstream); } Return Bitmap; }   

If someone knows how to do this, do not need WPF, please share!

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -