Bitmap bmp1 = new Bitmap(@"c:\coneimages\Cone_Images1.gif");
Bitmap bmp2 = new Bitmap(@"c:\coneimages\PictureBox_Images1.gif");
Bitmap bmp3 = new Bitmap(MergeTwoImages(bmp1,bmp2));
bmp3.Save(@"c:\coneimages\merged.bmp");
而且如何將兩張圖像合併爲一張圖像,並將兩張圖像合併爲一張圖像,然後再將第二張圖像合成一張?
public static Bitmap MergeTwoImages(Image firstImage, Image secondImage)
{
if (firstImage == null)
{
throw new ArgumentNullException("firstImage");
}
if (secondImage == null)
{
throw new ArgumentNullException("secondImage");
}
int outputImageWidth = firstImage.Width > secondImage.Width ? firstImage.Width : secondImage.Width;
int outputImageHeight = firstImage.Height + secondImage.Height + 1;
Bitmap outputImage = new Bitmap(outputImageWidth, outputImageHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (Graphics graphics = Graphics.FromImage(outputImage))
{
graphics.DrawImage(firstImage, new Rectangle(new Point(), firstImage.Size),
new Rectangle(new Point(), firstImage.Size), GraphicsUnit.Pixel);
graphics.DrawImage(secondImage, new Rectangle(new Point(0, firstImage.Height + 1), secondImage.Size),
new Rectangle(new Point(), secondImage.Size), GraphicsUnit.Pixel);
}
return outputImage;
}
但是,這不是我想要的我不知道如何以及如何尋找在谷歌。 我想要的是bmp1將會像bmp2一樣。 bmp1是透明的,我希望它像bmp2上的圖層一樣。
所以在bmp3中,我會看到整個正常bmp2與bmp1就可以了。
http://www.codeproject.com/Articles/6504/Transparency-Tutorial-with-C-Part – Ibki 2015-02-10 02:14:34