当我尝试使用以下方法将此位图绘制为 2 像素宽时,我创建了一个 1 像素宽和 256 像素高的位图:
public void DrawImage(Image image,RectangleF rect)
位图未正确绘制,因为每个位图列之间有白色细条纹。看下面的简单代码
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics gr = e.Graphics;
Bitmap bitmap = new Bitmap(1, 256);
for (int y = 0; y < 256; y++)
{
bitmap.SetPixel(0, y, Color.Red);
}
RectangleF rectf = new RectangleF();
for (int x = 0; x < 500; x++)
{
float factor = 2;
rectf.X = x*factor;
rectf.Y = 0;
rectf.Width = fact;
rectf.Height = 500;
// should draw bitmap as 2 pixels wide but draws it with white slim stripes in between each bitmap colomn
gr.DrawImage(bitmap, rectf);
}
}