Replies: 10 comments
-
@roland5572 You can use Imaging.CreateBitmapSourceFromHBitmap(IntPtr, IntPtr, Int32Rect, BitmapSizeOptions) Method (System.Windows.Interop) to use the System.Drawing.Image |
Beta Was this translation helpful? Give feedback.
-
@lindexi https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.imageformat If WPF can directly display the Image without additional image saving or rebuilding operation, this can significantly improve performance, especially for large images. image size 1920x1080 or above. |
Beta Was this translation helpful? Give feedback.
-
@roland5572 Thank you. And it will call IWICImagingFactory::CreateBitmapFromHBITMAP (wincodec.h). And WPF will use the WICBitmap type image to render in DirectX |
Beta Was this translation helpful? Give feedback.
-
@lindexi It is HBITMAP handle, can it process the .png or .jpg format? System.Drawing.Image class supports .png and .jpg format. If it can process the .jpg or .png via HBITMAP handle. I think if .net can provide a public method (eg. ImageSource.LoadImage(System.Drawing.Image image), These operations will be greatly simplified. stackoverflow has a complex method to convert System.Drawing.Image to WPF ImageSource. |
Beta Was this translation helpful? Give feedback.
-
@roland5572 Do you means how to show PNG or JPG image in WPF ? |
Beta Was this translation helpful? Give feedback.
-
One could probably make a subclass of |
Beta Was this translation helpful? Give feedback.
-
No, Mixed programming, namely WinForms+WPF, is a highlight of .net programing. System.Drawing.Image is the main class used to display pictures in Winforms. I think it is very necessary to directly support the System.Drawing.Image class in WPF. If format conversion is required (eg: convert the bytes), this may seriously affect the performance of the program. In fact, the user does not need to know whether he uses .jpg or .png, he only needs to pass a System.Drawing.Image parameter, and then the program can work normally. |
Beta Was this translation helpful? Give feedback.
-
The only use-case where this matters is when dealing with third party libraries which only accept System.Drawing.Image. While this feature is good-to-have, it's not very necessary. Especially since there are good workarounds (and these workarounds would also be used as an official WPF implementation). |
Beta Was this translation helpful? Give feedback.
-
This feature can simplify the mixed programming of WinForms and WPF. If users or third party libraries don't need mixed programming, it's not very necessary. If this feature is available, it will increase the connectivity of program and third-party libraries on nuget and github. |
Beta Was this translation helpful? Give feedback.
-
@roland5572 The issue is moved to discussion as of now. |
Beta Was this translation helpful? Give feedback.
-
WPF can use System.Windows.Media.ImageSource class to provide the image source to WPF controls.
But ImageSource cannot use System.Drawing.Image class as a source directly.
System.Windows.Media.ImageSource:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.imagesource
If this is a mixed programming of Winforms and WPF, the Winforms part needs to use System.Drawing.Image class to display image or bitmap. but now the WPF cannot accept the System.Drawing.Image class.
System.Drawing.Image
https://docs.microsoft.com/zh-cn/dotnet/api/system.drawing.image
Beta Was this translation helpful? Give feedback.
All reactions