本文介绍了WPF添加动态位图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题,我加上刚刚创建,但没有被存储在像位置的图像C:...
所以,如果有补充说,图像的WPF,而不需要它首先要保存的一种方法,我想知道......
的例子就是我想的。
位图位;
LoadBitmap(位);
图像=位;
解决方案
我发现在塔米尔Khason的博客解决方案的:
使用
公共静态的BitmapSource ConvertBitmap(System.Drawing.Bitmap源)
{
返回System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
source.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
}
您可以做
位图位;
LoadBitmap(位);
image.Source = ConvertBitmap(位);
I'm having problems adding an image I just created but which is not stored at a location like"C:..."
So I was wondering if there was a way of adding that image to the wpf without it being needed to be first saved ....
Example of what I would of want.
Bitmap bit;
LoadBitmap(bit);
image = bit;
解决方案
I've found a solution in Tamir Khason's blog here:
Using
public static BitmapSource ConvertBitmap(System.Drawing.Bitmap source)
{
return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
source.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
}
you could do
Bitmap bit;
LoadBitmap(bit);
image.Source = ConvertBitmap(bit);
这篇关于WPF添加动态位图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!