初始化Graphics类:private Graphics m_obj_OutputGraphics = null; m_obj_OutputImage = new Bitmap(m_int_Page_Width, m_int_Page_Highth); Graphics objGsOut = Graphics.FromImage(m_obj_OutputImage); Rectangle rctDraw = new Rectangle(0, 0, m_int_Page_Width, m_int_Page_Highth); m_mfImgData = new Metafile(strFilePath, objGsOut.GetHdc(), rctDraw, MetafileFrameUnit.Pixel); m_obj_OutputGraphics = Graphics.FromImage(m_mfImgData); m_obj_OutputGraphics.Clear(m_clBackGround);
调用下面方法保存图片: public void SaveJpgFile()
{
m_obj_OutputGraphics.Save();
//m_obj_OutputGraphics.Clear(m_clBackGround);
m_obj_OutputGraphics.Dispose();
m_mfImgData.Dispose();
}我在上面初始化Graphics类后,然后对该对象做一系列的画图,过程比较烦琐就不贴出来了,其中有个操作是将图片画到要出力的图片中.
public void CopyImageToJpg(string strImagePath, int int_StartPos_x, int int_StartPos_y)
{
MyString objMyStr = new MyString();
System.Drawing.Image img ;
Bitmap btImg;
try
{
btImg = new Bitmap(strImagePath);
}
catch(Exception ex)
{
btImg = new Bitmap(objMyStr.GetErrImagePath());
//throw new Exception(ex.Message);
}
img = System.Drawing.Image.FromHbitmap(btImg.GetHbitmap());
m_obj_OutputGraphics.DrawImage(img, int_StartPos_x, int_StartPos_y, m_int_ScreenImage_Width, m_int_ScreenImage_Hight); }
问题: 以上如果插入的图片数量比较少的话,一切正常,如果插入的图片数量比较多,最后就保存不下来处理完的图片了.不知道哪位大侠有过这方面经验啊?拯救一下小弟.
调用下面方法保存图片: public void SaveJpgFile()
{
m_obj_OutputGraphics.Save();
//m_obj_OutputGraphics.Clear(m_clBackGround);
m_obj_OutputGraphics.Dispose();
m_mfImgData.Dispose();
}我在上面初始化Graphics类后,然后对该对象做一系列的画图,过程比较烦琐就不贴出来了,其中有个操作是将图片画到要出力的图片中.
public void CopyImageToJpg(string strImagePath, int int_StartPos_x, int int_StartPos_y)
{
MyString objMyStr = new MyString();
System.Drawing.Image img ;
Bitmap btImg;
try
{
btImg = new Bitmap(strImagePath);
}
catch(Exception ex)
{
btImg = new Bitmap(objMyStr.GetErrImagePath());
//throw new Exception(ex.Message);
}
img = System.Drawing.Image.FromHbitmap(btImg.GetHbitmap());
m_obj_OutputGraphics.DrawImage(img, int_StartPos_x, int_StartPos_y, m_int_ScreenImage_Width, m_int_ScreenImage_Hight); }
问题: 以上如果插入的图片数量比较少的话,一切正常,如果插入的图片数量比较多,最后就保存不下来处理完的图片了.不知道哪位大侠有过这方面经验啊?拯救一下小弟.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货