Note that there are some explanatory texts on larger screens.

plurals
  1. POJpegs Rotated when Attempting to Decode from Byte Array to Display as Silverlight Image
    text
    copied!<p>My DB holds <code>byte[]</code> data for different images, <code>png</code> and <code>bmp</code> extensions work fine but strangely images with <code>jpeg</code> extension seem to be rotated 90deg anti-clockwise. I can only assume this is a problem with the encoder and decoder. The <code>jpegs</code> are encoded by an iPhone and decoded in a silverlight app using the following code:</p> <pre><code>using (MemoryStream ms = new MemoryStream(bImage, 0, bImage.Length)) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(ms); img.Source = bitmapImage; tempList.Add(img); } </code></pre> <p>For <code>bmps</code> I use the following: </p> <pre><code>ExtendedImage image = new ExtendedImage(); var bmp = new BmpDecoder(); var png = new PngEncoder(); try { bmp.Decode(image, new MemoryStream(bImage)); } catch (NotSupportedException) { new MessageWindow("Incorrect image format", DisplayStrings.ErrorDisplay, MessageButtons.OK, MessageImage.Error).Show(); continue; } MemoryStream ms = new MemoryStream(); png.Encode(image, ms); BitmapImage bi = new BitmapImage(); bi.SetSource(new MemoryStream(ms.ToArray())); img.Source = bi; tempList.Add(img); </code></pre> <p>Neither option will display the image in the correct orientation. Am I missing a specific jpeg decoder class?</p> <p><strong>EDIT</strong> As it turns out, the iPhone was doing something strange to the byte array. As a result: rotating the image on the iPhone before saving apparently does nothing to the image on the iPhone visibly but uploads the correct orientation of image onto the server. Why this happens is anyone's guess but it is so.</p>
 

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