错误信息: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);我百度了相关错误,但改了还是不行,请大家帮我看一下

解决方案 »

  1.   

    权限问题;
    问题出在 ”mHPHM.hHPHMImagePath“ 这个保存路径上;
      

  2.   

    oBitMap.Save(mHPHM.hHPHMImagePath, System.Drawing.Imaging.ImageFormat.Jpeg); 
    不就好了?为什么还要
     Bitmap oSaveImage = new Bitmap(iWidth, iHeight); 
                oSaveImage = System.Drawing.Image.FromHbitmap(oBitMap.GetHbitmap()); mHPHM.hHPHMImagePath 路径正确不?