【发布时间】:2014-12-11 05:20:36
【问题描述】:
基本上,我需要从现有位图 (this.Document.Bitmap) 创建一个新位图,然后用同一属性中的新位图替换现有位图。我也希望处理此克隆可能导致的任何额外内存,但我收到此错误。
using 块之外的语句导致抛出此异常,我不知道为什么。帮忙?
System.Drawing.dll 中出现“System.ArgumentException”类型的未处理异常。
using (Bitmap b = this.Document.Bitmap.Clone(new RectangleF() { Width = (int)this.croppingBorder.Width, Height = (int)this.croppingBorder.Height, X = (int)Canvas.GetLeft(this.croppingBorder), Y = (int)Canvas.GetTop(this.croppingBorder) }, this.Document.Bitmap.PixelFormat))
{
this.Document.Bitmap = b;
BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(b.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
image1.Source = bs;
}
canvas1.Width = this.Document.Bitmap.Width;
canvas1.Height = this.Document.Bitmap.Height;
【问题讨论】: