Var pb As New PictureBrush
#if TargetMacOS
pb.Image = CheckerboardPattern
#else
var f as double = me.ScaleFactor
var src as Picture = CheckerboardPattern.BestRepresentation(16, 16, f)
var p as new Picture(16 * f, 16 * f)
p.Graphics.DrawPicture(src, 0, 0, p.Width, p.Height, 0, 0, src.Width, src.Height)
p.HorizontalResolution = 72 * f
p.VerticalResolution = p.HorizontalResolution
pb.Image = p
#endif
pb.Mode = PictureBrush.Modes.Tile
g.Brush = pb
g.FillRoundRectangle(0, 0, g.Width, g.Height, g.Height, g.Height)
Note: If you inspect the picture ‘p’ in the debugger at a scaling <> 1.0 after the checkerboard pattern is drawn into it, you will see a incorrect result.
Sorry Garry, I must have been deceived by the checkerboard pattern. I have Windows set to 125 DPI. Then the difference is not so big. If I change to 200 DPI I see the same as in your screenshot. So it doesn’t work like that, because PictureBrush under Windows doesn’t care about the DPI of the image.
It seems that this works for every DPI setting under Windows: