我正在尝试重新上传图片大小。从我在网上找到的内容来看,实现这一点的方法是创建一个您想要的大小的新图像,然后使用图形将图像绘制为较小的图像。似乎适用于上传的所有图像,但尼康D90相机的图像除外。每当我尝试上传并重新设置这些图像的大小时,我都会在下面显示的行中看到OutOfMemoryException。任何人都可以告诉我我做错了什么。DrawImage导致OutOfMemoryException
'Create the new image as a blank bitmap
Dim resized As Image = New Bitmap(newWidth, newHeight)
'Create a new graphics object from the new image
Dim g As Graphics = Graphics.FromImage(resized)
'Resize graphics object to fit onto the resized image
g.DrawImage(originalImage, New Rectangle(0, 0, resized.Width, resized.Height)) <-- Exception
g.Dispose()
我正在使用FromFile。我得到了与FromStream相同的错误,但我猜测原因是一样的。图像将在Paint.Net中打开,如果我在Paint.Net中重新调整大小,然后上传它们,它们就可以正常工作。这对我的最终用户来说似乎是一个不必要的步骤。 BinaryReader解决方案涉及什么? – BLeB 2009-07-29 17:27:24