Convert ImageSource to BitmapImage - WPF

后端 未结 2 1323
北海茫月
北海茫月 2021-01-08 00:37

I\'m using a class library that generates a large ImageSource, > 3000x3750 pixels. I would like to convert this ImageSource to BitmapImage so that I can take advantage of De

相关标签:
2条回答
  • 2021-01-08 01:14

    The BitmapImage type inherits BitmapSource and ultimately ImageSource (both of which are abstract classes). You need to check what the actual type of your object is, i.e. check object.GetType().Name. If you're in luck, it may actually be returning a BitmapSource object and you will simply need to cast it to that type before being able to use it as such.

    0 讨论(0)
  • 2021-01-08 01:27

    I know it's a old post, but try doing:

    myBitmapImage = myImageSource as BitmapImage;
    

    That works well.

    0 讨论(0)
提交回复
热议问题