bootstrap easyui RunJS JSFiddle codepen Gist

C# 多张图片合成的问题

 //首先给出一个函数;用来将图片保存到内存中
private Image ReturnImage(string strPhotoPath)
{
FileStream fstream
= new FileStream(strPhotoPath, FileMode.OpenOrCreate, FileAccess.Read);
byte[] byData = new byte[fstream.Length];
fstream.Read(byData,
0, System.Convert.ToInt32(fstream.Length));
fstream.Close();


System.IO.MemoryStream stream
= new System.IO.MemoryStream(byData, true);
//stream.Write(byData,
0, byData.Length);//此句可省略,上一句构造函数已经将字节流塞进流了
Bitmap bmp
= new Bitmap(stream);
System.Drawing.Image image
= bmp;
return bmp;
}

private void Fold_Click(object sender, EventArgs e)
{
string str0 = "BOR/01/CAR.JPG";//像框文件的路径
string str1 = "BOR/01/A.JPG";//照片文件的全路径
string str2 = "BOR/01/L.JPG";//照片文件的全路径
string str3 = "BOR/01/A.JPG";//照片文件的全路径
string str4 = "BOR/01/2.JPG";//照片文件的全路径
string str5 = "BOR/01/6.JPG";//照片文件的全路径
string str6 = "BOR/01/3.JPG";//照片文件的全路径
Image img0 = ReturnImage(str0);
Image img1
= ReturnImage(str1);
System.Drawing.Image newImage
= img0.GetThumbnailImage(90, 22, null, new IntPtr());


//Graphics g = Graphics.FromImage(img0);这句话改成如下,以控制背景图片尺寸
Bitmap bmap = new Bitmap(90,22);
Graphics g
= Graphics.FromImage(bmap);

g.DrawImage(newImage, 0, 0, 90, 22);
g.DrawImage(img1,
13, 4, 11, 14);
img1
= ReturnImage(str2);
g.DrawImage(img1, (
float)29.5, 4, 11, 14);
img1
= ReturnImage(str3);
g.DrawImage(img1, (
float)41.5, 4, 11, 14);
img1
= ReturnImage(str4);
g.DrawImage(img1, (
float)53.5, 4, 11, 14);
img1
= ReturnImage(str5);
g.DrawImage(img1, (
float)65.5, 4, 11, 14);
img1
= ReturnImage(str6);
g.DrawImage(img1, (
float)77.5, 4, 11, 14);
this.pictureBox1.Image = img0;
}

posted @ 2012-08-09 18:03  lvyafei  阅读(450)  评论(0编辑  收藏  举报
博客地址:lvyafei 返回顶部   返回顶部   返回顶部 站长QQ,点击这里给我发消息
无觅关联推荐,快速提升流量