Asp.net mvc CreateBitmap-参数无效,图像大小为9000*9000
创建newBitmap后,我收到异常-参数无效, 当我想要创建9000*9000像素的图像时。我需要创建大分辨率图像。由于这个错误,我无法创建大图像 我的RAM是16GB。我的系统是64位的。有时它也会发生在记忆之外。 如何解决这个问题 这是我的密码Asp.net mvc CreateBitmap-参数无效,图像大小为9000*9000,asp.net-mvc,c#-4.0,bitmap,bitmapimage,Asp.net Mvc,C# 4.0,Bitmap,Bitmapimage,创建newBitmap后,我收到异常-参数无效, 当我想要创建9000*9000像素的图像时。我需要创建大分辨率图像。由于这个错误,我无法创建大图像 我的RAM是16GB。我的系统是64位的。有时它也会发生在记忆之外。 如何解决这个问题 这是我的密码 private Bitmap createBigImage(Bitmap layerBitmap, int newWidth, int newHeight) { Bitmap newBitmap = new Bit
private Bitmap createBigImage(Bitmap layerBitmap, int newWidth, int newHeight)
{
Bitmap newBitmap = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppArgb);
using (Graphics gr = Graphics.FromImage(newBitmap))
{
gr.SmoothingMode = SmoothingMode.HighQuality;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
gr.DrawImage(layerBitmap, new Rectangle(0, 0, newWidth, newHeight));
gr.Dispose();
}
return newBitmap;
}
Bitmap newbitmap = createBigImage(bitmap, 9000, 9000);
真正的问题可能是没有处理
newbitmap
的实例。但是,在什么意义上您需要9000x9000
图像?我相信无论你们想做什么都可以做得更好。在64位进程中应该可以做得很好。宽度(每像素9000*4字节)尚未达到每行64K的限制()。您能确认您的代码在64位进程中运行吗?当我运行您的代码作为位图
参数传入JPG文件时,我得到了相同的参数无效
错误。输入完整的路径名解决了这个问题。也许你应该看看你的输入?大小似乎不是问题(我尝试了10000)。在哪一行您会得到错误?堆栈跟踪的完全异常?目前尚不清楚问题在于位图的大小。。或者是别的什么?