Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't save an Image to MemoryStream
    primarykey
    data
    text
    <p>I am trying to save an image to a <code>MemoryStream</code> to get a byte array. </p> <pre><code> using (MemoryStream ms = new MemoryStream()){ // Convert Image to byte[] ms.Seek(0, SeekOrigin.Begin); img.Save(ms, ImageFormat.RawFormat); byte[] imageBytes = ms.ToArray(); return imageByates; } </code></pre> <p>This piece of code works for an image with the following properties</p> <pre><code>Flags 77840 FrameDimensionList System.Guid[] Heigth 2048 HorizontalResolution 72 Palette System.Drawing.Imaging.ColorPalette PhysicalDimension {Width=1322, Height=2048} Pixelformat Format24bppRgb PropertyIDList 0 20625 PropertyIDList 1 20624 PropertyIDList 2 34675 PropertyItems System.Drawing.Imaging.PropertyItem PropertyItems 0 System.Drawing.Imaging.PropertyItem PropertyItems 1 System.Drawing.Imaging.PropertyItem PropertyItems 2 System.Drawing.Imaging.PropertyItem RawFormat [ImageFormat: b96b3cae-0728-11d3-9d7b-0000f81ef32e] RawFormat height 2048 width 1322 Tag VerticalResolution 72 Width 1322 </code></pre> <p>I get the infamous a Generic Error Occured in gdi+ for another image with following properties</p> <pre><code>Flags 73744 FrameDimensionList System.Guid[] Heigth 336 HorizontalResolution 96 Palette System.Drawing.Imaging.ColorPalette PhysicalDimension {Width=251, Height=336} Pixelformat Format24bppRgb RawFormat [ImageFormat: b96b3cae-0728-11d3-9d7b-0000f81ef32e] RawFormat height 336 width 251 Tag VerticalResolution 96 Width 251 </code></pre> <p>The difference, is former is a jpeg image I loaded from filesystem (using <code>Image.FromFile</code>). The latter is an image I receive through an SDK, which presumably take it out of a database stored in the network. The images are both <code>System.Drawing.Image</code></p> <p>What could be the issue here ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload