程式碼不解釋
PS:我自己寫的執行不會有錯誤
圖片合成程式碼


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 public class compositeImage
{
public void addimageadd(string[] images)
{
string str0 = images[1];
Image img0 = ReturnImage(str0);
System.Drawing.Image newImage = img0.GetThumbnailImage(img0.Width, img0.Height, null, new IntPtr());
Graphics g = Graphics.FromImage(newImage);
g.DrawImage(img0, 0, 0, img0.Width, img0.Height);
for (int i = 2; i < images.Length; i++)
{
string str1 = images[i];
Image img1 = ReturnImage(str1);
g.DrawImage(img1, 0, 0, img1.Width, img1.Height);
}
newImage.Save(images[0], ImageFormat.Bmp);
}
private static 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;
}
}


用法
(第一個參數是要存檔的路徑第二個變數之後是依序要合成的圖片)
1
2
3
 string[] data = { "C://haha007.bmp", "C://ad201401240003.png", "C://aa90.png", "C://aa360.png" };
compositeImage pcg = new compositeImage();
pcg.addimageadd(data);

有人有問題再問我吧
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()