0

I need to gray scale a image before it gets displayed. Image is coming from server. I used BitmapImage as a Source of Image. I am able to show image using BitmapImage.

Now I need to grayscale image, for that I found that WritableBitmap can be used to convert it to grayscale. I used WritableBitmapEx.WinRT library for gray scale.

but the issue is I am not able to convert BitmapImage to WritableBitmap in WinRT.

Any suggestions are welcome.

Thanks

vITs
  • 1,651
  • 12
  • 30

1 Answers1

0

Use a WriteableBitmap instead of the BitmapImage to begin with. Other than access to the PixelBuffer they can be used almost identically.

You can't directly extract the pixels from a BitmapImage. All of the reasonable methods to "convert" a BitmapImage to a WritableBitmap get the data from the original source. If you can't get the original UriSource (since you loaded from stream) and don't have the stream available to reload from you're out of luck.

The only other (ugly) option is to snapshot the Image with RenderTargetBitmap

Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54
  • I have used WritableBitmap directly as binding of image's source. Earlier it was binded to url of image. I am getting urls in web service response and they are too many. If I directly use WritableBitmap then I need to create WritableBitmap in webservice itself so that it will get displayed when done as property of type WritableBitmap is directly binded to image src. This needed to done on UI thread. But its taking time to create random stream from url and then opening that stream to create WritableBitmap. Here I need to wrap this for around 20 to 30 images, which need to show at a same time. – vITs Mar 20 '16 at 03:23