上传图片抛出异常(内存不足)
代码: public string UpLoadPhoto(string serPath, string fullName, int width, int height)
{
System.Drawing.Image oldImage, newImage;
System.Drawing.Image.GetThumbnailImageAbort call = new System.Drawing.Image.GetThumbnailImageAbort(CallBack);
oldImage = System.Drawing.Image.FromFile(fullName);
int nWidth, nHeight;
if (oldImage.Width > width || oldImage.Height > height)
{
nWidth = oldImage.Width;
nHeight = oldImage.Height;
while (nWidth > width)
{
int i = 100;
i = i - 1;
nWidth = nWidth * i / 100;
nHeight = nHeight * i / 100;
}
while (nHeight > height)
{
int i = 100;
i = i - 1;
nHeight = nHeight * i / 100;
nWidth = nWidth * i / 100;
}
}
else
{
nWidth = oldImage.Width;