//pictureBox1的图案为背景,pictureBox2放于背景上,形成pictureBox3的图案
private void button3_Click(object sender, EventArgs e)
{
Image imgBackgroud = pictureBox1.Image; //背景图
Image imgForegroud = pictureBox2.Image; //前景图
Graphics g = Graphics.FromImage(imgBackgroud);
g.DrawImage(imgForegroud,
new Rectangle(0, 0, imgForegroud.Width, imgForegroud.Height),
new Rectangle(0, 0, imgForegroud.Width, imgForegroud.Height),
GraphicsUnit.Pixel);
g.Dispose();
pictureBox3.Image = imgBackgroud; //叠加的图
}
//打开图像,载入图片到pictureBox1
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofdlg = new OpenFileDialog();
// ofdlg.Filter = "BMP File(*.bmp)|*.bmp";
ofdlg.Filter = "(图片文件)|*.jpeg;*.jpg;*.bmp;*.png;*.gif";
if (ofdlg.ShowDialog() == DialogResult.OK)
{
Bitmap image = new Bitmap(ofdlg.FileName);
pictureBox1.Image = image;
}
}
//打开图像,载入图片到pictureBox2
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog ofdlg = new OpenFileDialog();
// ofdlg.Filter = "BMP File(*.bmp)|*.bmp";
ofdlg.Filter = "(图片文件)|*.jpeg;*.jpg;*.bmp;*.png;*.gif";
if (ofdlg.ShowDialog() == DialogResult.OK)
{
Bitmap image = new Bitmap(ofdlg.FileName);
pictureBox2.Image = image;
}
}
记录一下,虽然比较简单,1个图案放于另外一个图片上面。