FillRectangle unwanted border on MouseCursor

Hi, I have a method that changes the mouse cursor on window launch. The mouse cursor is a crosshair that I’ve drawn using Graphics.FillRectangle. The problem I’m having is that when the cursor is over a white background, there’s a sort of grey outline around the white area of the cross. Am I missing some important Graphics call? The code is:

Var c as MouseCursor
c = new MouseCursor(GetCrosshairPicture, 12, 12)
Self.MouseCursor = c

and GetCrosshairPicture is:

Public Function GetCrosshairPicture() as Picture

Var p as new Picture(24, 24)
Var g as Graphics = p.Graphics

g.DrawingColor = Color.White

g.FillRectangle(0.0, 10.0, 24.0, 4.0) //horizontal
g.FillRectangle(10.0, 0.0, 4.0, 24.0) //vertical

g.DrawingColor = Color.Black

g.FillRectangle(1.0, 11.0, 22.0, 2.0) //horizontal
g.FillRectangle(11.0, 1.0, 2.0, 22.0) //vertical

return p

End Function

As it’s a mouse pointer I can’t take a screenshot of the result, here are photos, one on a white background (not OK) and one on the Big Sur desktop background (OK, but I can slightly see the grey outline)

IMG_8165
IMG_8164

Got it. For some reason just posting on here gets me to find the right article! :slight_smile:

After reading this blog post: http://blog.xojo.com/2016/04/05/xojo-retinahidpi-the-journey-of-a-thousand-pixels/

I found out that it’s a retina issue, so instead of:

Var p as new Picture(24, 24)

I use the following:

Var p as Picture
p = Self.BitmapForCaching(24, 24)

And it all works fine :+1:

2 Likes