>_DD wrote:
>It seems that there is some odd interaction with LinearGradientB rush
that depends on positioning. A simple test:
Rectangle Square = new Rectangle(..... );
in Paint:
LinearGradientB rush ShadeBrush = new LinearGradientB rush(
Square, Color.White, Color.Black, 90.0F, true);
g.FillRectangle (ShadeBrush, Square);
This sometimes works as expected, but sometimes draws a one-
pixel BLACK line across the top edge.
On Thu, 11 Jan 2007 20:40:24 +0100, "Bob Powell [MVP]"
>This is a known problem
It's a Microsoft bug? Well, at least I only wasted a day and a half on
it (damn, damn, damn). Has anyone filed the bug with Microsoft? (They
don't seem to take those very seriously)
Having assumed that the MS library would have been debugged by now, I
ended up writing lots of test code, converting back and forth from
float to int, etc. Pretty tough debugging, given that the app uses
animation, and it was turning up seemingly at random.
From one test, I found that moving a drawn object from Y=249 to Y=250
introduced the black line. That magic number also changed when the
object's size was changed. Since the graphics in this case require
smooth animation of object position and size, the lines were popping
in an out all over the screen as the objects crossed these magical
borders (what determines that?). It looked horrible, of course.
I didn't turn up any mention of this artifact in google searches. (I
even checked your FAQ, Bob. You may want to add this)
>. A workaround is to make the brush area slightly
larger than the area to be filled. (1 pixel bigger)
I had tried inflating the brush, and it seemed to eliminate the random
line. But it introduced its own problems:
Some of the shaded areas get as narrow as 3 pixels (perspective-shrink
during animation). That means that a 1-pixel miss results in a very
visible 33% change in the outer color. This is not as ugly as the
black lines, but still a noticeable glitch.
And with the inflated brush, there's now no way to get a pure white or
pure black row of pixels on the outer edge of a 3 pixel wide object,
as the crossfade is already at 20% (1 pixel out of 5) when the brush
hits the object edge. But then the bug will pop in and randomly draw a
pure white or black edge.
--
Bob, have you worked with this enough to know:
Does this occur with other, nonlinear, gradient types? That could be
a workaround.
Does antialiasing fix this?
Is this a deeper problem than just two MS guys who didn't round in the
same direction? Early on, I tried writing my own gradient using a
series of Pens, but that seemed to do the same thing. That would
indicate a bug inherent to the internal coordinate mechanism.