Convert ImageSource to BitmapImage - WPF

后端 未结 2 1162
梦谈多话
梦谈多话 2021-01-08 00:55

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:19

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

    myBitmapImage = myImageSource as BitmapImage;
    

    That works well.

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

    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)
提交回复
热议问题