HBITMAP to Bitmap in WinUI 3 #7921
-
There using to be System.Drawing.Image.FromHbitmap in .Net Framework, but I don't know how to do the same in WinUI. I have handle to HBITMAP. Have looked at several places. But don't know how to create objects of type Bitmap, BitmapSource, ImageSource from HBITMAP. Basically I want to draw it on a control such as StackPanel etc. Kindly please help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I generally use a WriteableBitmap (you can see for example the GetCaptureWriteableBitmap function that I used in CMediaEngine.cs to convert a HBITMAP (m_hBitmapCapture) that I set as Image.Source in SaveFrameDialog function in MainWindow.xaml.cs) |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot @castorix . You have helped me several times . God bless. Today. on another forum also, I found your answer very useful. |
Beta Was this translation helpful? Give feedback.
-
So you're creating a new in-memory bitmap, rendering to it, and then copying it to the |
Beta Was this translation helpful? Give feedback.
I generally use a WriteableBitmap (you can see for example the GetCaptureWriteableBitmap function that I used in CMediaEngine.cs to convert a HBITMAP (m_hBitmapCapture) that I set as Image.Source in SaveFrameDialog function in MainWindow.xaml.cs)