1

I have loaded image im my app with type ImageSource, and I want to share it, but I need to convert image to IRandomAccessStream.

For e.g.:

  ImageSource _myLoadedImage; 
  IRandomAccessStream ras; 
  //Some code when _myLoadedImage convert to IRandomAccessStream 
  RandomAccessStreamReference.CreateFromStream(ras);

How can I do that?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Viacheslav
  • 151
  • 1
  • 13

1 Answers1

2

There's not really a way to get at the pixel buffer unless it's a WriteableBitmap. If you have the original image data stream/file (ie a png or jpeg) you can use the decoder to get at it and later convert that into an image source. I do something like this in my blogpost here: http://www.iter.dk/post/2012/10/08/Using-User-Provided-Images-for-Secondary-Tiles.aspx

dotMorten
  • 1,953
  • 1
  • 14
  • 10
  • I have image in .jpeg, and i can conver to BitmapImage. Does it help me? Can i convert this to IRandomAccessStream (without saving file in folders)? – Viacheslav Feb 03 '13 at 16:34
  • Yes. Look at the first part of the sample that loads the image with the decoder and then goes through the stream pixel by pixel – dotMorten Feb 05 '13 at 15:25