日期:2014-05-20  浏览次数:21089 次

GDI+一般性错误。 byte[]转换为图像的时候。
 //创建新图位图   
                   Image im = byteArrayToImage(imgbyte);
                    Bitmap bitmap = new Bitmap(width, height);
                    //创建作图区域   
                    Graphics graphic = Graphics.FromImage(bitmap);
                    graphic.DrawImage(im, 0, 0, new Rectangle(x, y, width, height), GraphicsUnit.Pixel);
                    //从作图区生成新图
                            IntPtr pr = bitmap.GetHbitmap();
                            Image MyImage = Image.FromHbitmap(pr);
                            DeleteObject(pr);
                           byte[] tmpbyte = imageToByteArray(MyImage);                   
                           
                            Image newimage = byteArrayToImage(tmpbyte);
                            byteslen += tmpbyte.Length;
                            x = x + width;
                            newimage .Save("C:\\newfilepath\\im.jpg", ImageFormat.Jpeg); //GDI一般性错误                         
                            MyImage.Dispose();
                     如果是: MyImage.Save("C:\\newfilepath\\im.jpg", ImageFormat.Jpeg);//这个没有问题。

        /// <summary>
        /// byte[]数组转换为 Image
        /// </summary>
        /// <param name="byteArrayIn"></param>