日期:2014-05-18  浏览次数:20461 次

上传图片抛出异常(内存不足)
代码:   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;