0
votes

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

1
Seen that! its getting stream from file - vITs

1 Answers

0
votes

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