我正在使用以下代码在大图像上绘制小图像,但它有白线,
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中的图像,填充了红色。
谢谢, 约翰尼
答案 0 :(得分:0)
尝试以下代码
graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;