我正试图在picturebox中的另一个图像上绘制一个图像。它们的尺寸相同(125X150(。当我在图片框中的[0,0]点绘制第二张图片时,这两张图片没有对齐。这是我的代码:
pictureBox1.Image = Image.FromFile("picture\faces\face3.png");
Bitmap bmp = new Bitmap(pictureBox1.Image);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(new Bitmap("picture\faces\eyebow1.png"), new Point(0, 0));
g.Dispose();
pictureBox1.Image = bmp;
我自己想出来的。虽然我不知道为什么:
pictureBox1.Image = Image.FromFile("picture\faces\face3.png");
Bitmap bmp = new Bitmap(pictureBox1.Image);
Console.WriteLine(bmp.Width);
Graphics g = Graphics.FromImage(bmp);
pictureBox1.Image = Image.FromFile("picture\faces\eyebow1.png");
g.DrawImage(new Bitmap(pictureBox1.Image), new Point(0, 0));
g.Dispose();
pictureBox1.Image = bmp;