2016-06-17 2 views
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 */ 

문제는 내 사각형 선 및 채우기 사이 공백의 픽셀처럼 볼 수 있습니다 : 여기

는 코드입니다.

enter image description here

이 문제를 해결하는 방법에 대한 어떤 단서?

+1

'Fill' 전체 사각형 (+1 오프셋을 제거), 다음'imgur가 나를 위해 차단되기 때문에 Draw' –

+0

내가 이미지를 볼 수는 없지만, 당신은 SolidBrush 그것을 시도? – hometoast

+0

역순으로 작업을 시도 했습니까? 오프셋 계산 (예 : 전체 사각형 채우기)없이 채우기를 시도한 다음 테두리를 그립니다. – itsme86

답변

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); 
0

추가 한 추가 픽셀을 제거해보십시오.