0

我正在使用以下代码在大图像上绘制小图像,但它有白线,

Bitmap bitmap = new Bitmap(1000, 1000);
Graphics graphic = Graphics.FromImage(bitmap);

Bitmap bitmap1 = new Bitmap(256, 256);
Graphics g1 = Graphics.FromImage(bitmap1);
g1.FillRectangle(new SolidBrush(Color.Red), new Rectangle(-10, -10, 300, 300));
g1.Flush();

graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;

graphic.DrawImage(bitmap1, new RectangleF(0f, 313.5f, 256, 256));
graphic.DrawImage(bitmap1, new RectangleF(0f, 569.5f, 256, 256));

bitmap.Save("1.png");
Process.Start("1.png");

有人能告诉我为什么会这样吗?

tile.png 是 256X256 的图像,填充了红色。

4

1 回答 1

0

试试下面的代码

graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
于 2012-11-15T10:38:26.703 回答