Working in WPF and C#, I have a TransformedBitmap object that I either:
- Need to save to disk as a bitmap type of file (ideally, I’ll allow users to choose whether it’s saved as a BMP, JPG, TIF, etc, though, I’m not to that stage yet…)
- Need to convert to a BitmapImage object as I know how to get a byte[] from a BitmapImage object.
Unfortunately, at this point I’m really struggling to get either one of those two things done.
Can anyone offer any help or point out any methods I might be missing?
All of your encoders are using
BitmapFrameclass for creating frames that will be added toFramescollection property of encoder.BitmapFrame.Createmethod has variety of overloads and one of them accepts parameter ofBitmapSourcetype. So as we know thatTransformedBitmapinherits fromBitmapSourcewe can pass it as a parameter toBitmapFrame.Createmethod. Here are the methods which works as you have described:They accept any BitmapSource as the first parameter and any BitmapEncoder as a generic type parameter.
Hope this helps.