#region
图片合成
public byte [] WritePic(ArrayList _al, int _width, int _height)
{
// System.Collections.ArrayList;
byte [] pic_by;
System.IO.MemoryStream Ms,imgms;
Bitmap bmp;
System.Drawing.Image img0;
try
{
Ms = new System.IO.MemoryStream();
bmp = new Bitmap(_width,_height);
bmp.Save(Ms,System.Drawing.Imaging.ImageFormat.Jpeg);
img0 = System.Drawing.Image.FromStream(Ms);
int i_top = 0 ;
for ( int pic_i = 0 ;pic_i < _al.Count;pic_i ++ )
{
Graphics gp = Graphics.FromImage(img0);
System.Drawing.Image img = System.Drawing.Image.FromStream( new System.IO.MemoryStream(( byte [])_al[pic_i]));
Bitmap bmp1 = new Bitmap(img);
gp.DrawImage(bmp1, new System.Drawing.Rectangle( 0 ,i_top,bmp1.Width,bmp1.Height), 0 , 0 ,bmp1.Width,bmp1.Height,System.Drawing.GraphicsUnit.Pixel);
i_top += bmp1.Height;
gp.Dispose();
img.Dispose();
bmp1.Dispose();
}
imgms = new System.IO.MemoryStream();
img0.Save(imgms,img0.RawFormat);
imgms.Position = 0 ;
pic_by = new byte [imgms.Length];
imgms.Read(pic_by, 0 ,pic_by.Length);
Ms.Close();
imgms.Close();
bmp.Dispose();
img0.Dispose();
return pic_by;
}
catch (Exception pic_e)
{
// WriteLog(DateTime.Now+"\t"+str_pz_wfbh+"\t图片合成失败"+pic_e.Message);
return null ;
}
}
#endregion
}
public byte [] WritePic(ArrayList _al, int _width, int _height)
{
// System.Collections.ArrayList;
byte [] pic_by;
System.IO.MemoryStream Ms,imgms;
Bitmap bmp;
System.Drawing.Image img0;
try
{
Ms = new System.IO.MemoryStream();
bmp = new Bitmap(_width,_height);
bmp.Save(Ms,System.Drawing.Imaging.ImageFormat.Jpeg);
img0 = System.Drawing.Image.FromStream(Ms);
int i_top = 0 ;
for ( int pic_i = 0 ;pic_i < _al.Count;pic_i ++ )
{
Graphics gp = Graphics.FromImage(img0);
System.Drawing.Image img = System.Drawing.Image.FromStream( new System.IO.MemoryStream(( byte [])_al[pic_i]));
Bitmap bmp1 = new Bitmap(img);
gp.DrawImage(bmp1, new System.Drawing.Rectangle( 0 ,i_top,bmp1.Width,bmp1.Height), 0 , 0 ,bmp1.Width,bmp1.Height,System.Drawing.GraphicsUnit.Pixel);
i_top += bmp1.Height;
gp.Dispose();
img.Dispose();
bmp1.Dispose();
}
imgms = new System.IO.MemoryStream();
img0.Save(imgms,img0.RawFormat);
imgms.Position = 0 ;
pic_by = new byte [imgms.Length];
imgms.Read(pic_by, 0 ,pic_by.Length);
Ms.Close();
imgms.Close();
bmp.Dispose();
img0.Dispose();
return pic_by;
}
catch (Exception pic_e)
{
// WriteLog(DateTime.Now+"\t"+str_pz_wfbh+"\t图片合成失败"+pic_e.Message);
return null ;
}
}
#endregion
}
本文转自钢钢博客园博客,原文链接:http://www.cnblogs.com/xugang/archive/2008/03/08/1096559.html,如需转载请自行联系原作者