wpf如何将BitmapSource转为bitmap?
如题,以前做winfrom时做的图片处理类,现在换到wpf发现不太好用,请教如何将image中的Source读到bitmap中?source是由bitmap转过来的pri...
如题,以前做winfrom时做的图片处理类,现在换到wpf发现不太好用,请教如何将image中的Source读到bitmap中?
source是由bitmap转过来的
private BitmapSource bs(Bitmap bt)
{
IntPtr ip = bt.GetHbitmap();
BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
ip, IntPtr.Zero, Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
DeleteObject(ip);
return bitmapSource;
}
然后imimg1.Source = bitmapSource; 展开
source是由bitmap转过来的
private BitmapSource bs(Bitmap bt)
{
IntPtr ip = bt.GetHbitmap();
BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
ip, IntPtr.Zero, Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
DeleteObject(ip);
return bitmapSource;
}
然后imimg1.Source = bitmapSource; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询