GDI+ 中发生一般性错误
错误信息:GDI+ 中发生一般性错误。
代码如下:
int iWidth = rect.Width - rect.X;
int iHeight = rect.Height - rect.Y;
string strImagePath = mHPHM.hImagePath;
//载入底图
System.Drawing.Image oFromImg = System.Drawing.Image.FromFile(strImagePath);
//创建新图位图
System.Drawing.Bitmap oBitMap = new System.Drawing.Bitmap(iWidth, iHeight);
//创建作图区域
System.Drawing.Graphics oGraphic = System.Drawing.Graphics.FromImage(oBitMap);
//截取原图相应区域写入作图区
oGraphic.DrawImage(oFromImg, 0, 0, new Rectangle(rect.X, rect.Y, iWidth, iHeight), GraphicsUnit.Pixel);
//从作图区生成新图
Bitmap oSaveImage = new Bitmap(iWidth, iHeight);
oSaveImage = System.Drawing.Image.FromHbitmap(oBitMap.GetHbitmap());
//保存图象
oSaveImage.Save(mHPHM.hHPHMImagePath, System.Drawing.Imaging.ImageFormat.Jpeg);
我百度了相关错误,但改了还是不行,请大家帮我看一下