Graphics.Pixel(X, Y) in Windows and OSX

I use this code in Windows:

Dim c as Color c = me.Graphics.Pixel(X, Y)

Why in OSX don’t work?

Sorry, I forgot to mention that I use it inside a canvas.

Since 2016R1 because of HiDPI support, Graphics.Pixel has been deprecated.

Use [url=http://documentation.xojo.com/index.php/Rgbsurface]RGBSurface.Pixel/url instead.

How? I’m in MouveUp event and In me I don’t have RGBSurface…

how do you paint your canvas?
if you use backdrop or any other picture then you can get the rgbsurface of that object
otherwise you can’t use pixel

me.graphics has been deprecated for several years. It should not be used. All painting must take place in Paint.

In Paint, you can actually still use Pixel to draw. This works :

Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.pixel(0,0) = &cFF0000 End Sub

But you can’t get the color of a pixel with g.

Here is a way to get to the pixel in MouseUp :

[code]Sub MouseUp(X As Integer, Y As Integer)
dim p as new picture(me.width, me.Height)
me.DrawInto(p.graphics, 0, 0)

Dim c as Color
c = p.RGBSurface.Pixel(0, 0)

msgbox str(c)

End Sub
[/code]

Incidentaly, that will work no matter which way it was painted or placed into backdrop.

thank you so much!