简体   繁体   中英

How to convert a CroppedBitmap to BitmapImage

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.

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.

you can try this Bitmap bm = new Bitmap(Image file path or image stream); after that use the save function like this bm.Save(Image path,format);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM