Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a CroppedBitmap to BitmapImage

Tags:

c#

wpf

I am trying to convert a CroppedBitmap to BitmapImage * EDIT:Without using a memorystream.*

I have tried to directly convert it, seems that is not an option. This should't be that hard.

I am attempting to cut out part of a BitmapImage, and create a BitmapImage that contains only the new cropped Bitmap.

like image 889
General Grey Avatar asked Jan 22 '14 06:01

General Grey


1 Answers

It would seem a BitmapImage is a specialized version of BitmapSource (which is what a CroppedBitmap is). You can easily convert from Image to source, but not the otherway around.

This answer likely works, though I never looked into it.

BitmapSource to BitmapImage

The easiest solution for me was to convert all my BitmapImages into BitmapSources. I didn't even have to edit any other code. I guess I wasn't using the specialized parts.

like image 156
General Grey Avatar answered Nov 12 '22 07:11

General Grey