A possible GDI+ bug
Avishkar Autar · Jan 26 2010 · .NET Platform
This involved drawing a filled rectangle with a TextureBrush, using a 1x[whatever] texture and setting it to be tiled.
TextureBrush tb = new TextureBrush(firesync.Properties.Resources.target_highlight2_run);
tb.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
e.Graphics.FillRectangle(tb, 0, 0, 32, 32);
The code above works correctly and here is what it produces,
Unfortunately if the y (top) coordinate of the rectangle is changed to anything other than 0, the rendering gets screwed up. Here is what occurs if the y-coordinate is set to 1 (which should, effectively, push everything down 1 pixel),
However, there is a way to hack around the issue, keep the y-coordinate at 0 and use Graphics.TranslateTransform() to do the y translation.
TextureBrush tb = new TextureBrush(firesync.Properties.Resources.target_highlight2_run);
tb.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
e.Graphics.TranslateTransform(0, 1);
e.Graphics.FillRectangle(tb, 0, 0, 32, 32);