我有一个C#winforms,我在这里绘制一个矩形然后填充它。
以下是代码:
LinearGradientBrush secondGradient = new LinearGradientBrush(frontRect, Color.FromArgb(255, 190, 171, 18), Color.FromArgb(255, 152, 186, 27), 90);
/* second row element */
g.DrawRectangle(pen, leftInsertionBox);
g.FillRectangle(secondGradient, leftInsertionBox.X + 1, leftInsertionBox.Y + 1, leftInsertionBox.Width - 1, leftInsertionBox.Height - 1);
g.DrawRectangle(pen, leftCoverBox);
g.FillRectangle(secondGradient, leftCoverBox.X + 1, leftCoverBox.Y + 1, leftCoverBox.Width - 1, leftCoverBox.Height - 1);
/* second row element */
问题是我可以在矩形线和填充之间看到像白色空格的像素。
关于如何解决这个问题的任何线索?
答案 0 :(得分:1)
我会尝试撤消操作。首先进行填充操作,删除偏移计算(即填充整个区域),然后绘制边框。
g.FillRectangle(secondGradient, leftInsertionBox.X, leftInsertionBox.Y, leftInsertionBox.Width, leftInsertionBox.Height);
g.DrawRectangle(pen, leftInsertionBox);
g.FillRectangle(secondGradient, leftCoverBox.X, leftCoverBox.Y, leftCoverBox.Width, leftCoverBox.Height);
g.DrawRectangle(pen, leftCoverBox);
答案 1 :(得分:0)
尝试删除您添加的额外像素。