0
我有一个C#winforms,其中我绘制一个矩形,然后填充它。C#填充矩形留下一个空白区域
下面是代码:
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 */
的问题是,我可以看到像我的矩形线条和填充之间的空白像素。
如何解决这个任何线索?
首先'Fill'整个矩形(删除+1的偏移量),然后'Draw' –
我看不到图像,因为imgur被阻止我,但你有一个SolidBrush尝试过吗? – hometoast
你有没有尝试以相反的顺序进行操作?我试着做填充,没有任何偏移量计算(即填充整个矩形),然后绘制边界。 – itsme86