Hi,
I’m just taking baby steps with Xojo (I’ve got a design and filemaker background). I picked up the book “I wish I knew how to program the canvas control” and I’ve gotten to example 1-6 which is just a simple canvas with the paint event and the following code:
'Draw a green filled rectangle
g.ForeColor = RGB(10, 240, 10) 'Green
g.FillRect(49, 49, 100, 100) 'Filled Rectangle
'Colour the centre pixel red
g.Pixel(99, 99) = RGB(240, 10, 10)
'Get the pixel values outside and inside the Rectangle
MsgBox "The colour inside the rectangle is: " + CStr(g.Pixel(60,60)) + chr(13) +"The colour outside the Rectangle is: " + CStr(g.Pixel(20,20))
This crashes on the last line, something to do with the g.Pixel(60,60), any idea why?
g here (in the paint event) can be considered a temporary graphic.
You can send to it, but you cant read from it.
If you want to know what pixels are what, you are better off creating a picture
Drawing to the picture’s rgbsurface
Reading from the picture’s rgbsurface
and in the Paint event where you have this g, just g.drawpicture thepicture, 0,0 to display your picture
Thanks Jeff and Michel, I’ll try it later today. I was trying it last night using that link and getting pretty frustrated, two steps forward, one back.