RGBsurface creation

I tried to create an RGBsurface with the following in the open event of the view but the size of the canvas is always 100x100. When is the Canvas actually created to its real size in the App or do I need a timer run and create the surface there?

MapPic = new Picture(canvas1.width, canvas1.height)
surf = MapPic.RGBSurface

Use the canvas paint event or view/screen activate event.

The Activate event didn’t work but the Paint event did, thanks.
New problem is that the color returned from the surface doesn’t seem to work??

Is there anyway to see the contents of the RGBSurface?

If you have MBS, use this:

Var gmpic As New GMImageMBS(pic)
Var GMcol As gmcolormbs 
var XojoCol as color

GMCol =  gmpic.pixelColor(20,20)
XojoCol = Color.RGB(GMcol.redQuantum,GMcol.greenQuantum,GMcol.blueQuantum)

Also, I note you are creating a picture at the same size as the canvas, and drawing on that.
Thats how I do stuff on Mac and Windows.
Working in 2020R2 in iOS, I am finding it is faster to redraw everything in Paint, than to draw offscreen and copy my offscreen image to canvas during a paint event.
Makes no sense to me , but…

So you may find
g.drawpicture Map3,0,0…
instead of
MapPic.graphics.drawpicture Map3,0,0…
works better as you don’t need a second .drawpicture to get it on screen

MBS Only for Desktop??

I thought I had to do it that way to assign the picture to the RGBSurface, can you assign a jpg from your resources directly to the RGBSurface also? In IOS/Mobile I am not getting any pixel color readings correctly but seem to have it working on Desktop ok.
Jeremie suggested I put the creation of the surface in the paint event which made it seemingly create the surface correctly to the size I wanted but I am a bit nervous as it says it is memory intensive and would get created every time the paint event fires but I assume it is ok if Jeremie says unless I have interpreted incorrectly.

No!!! And yee-hah, hurrah !

Xojo ‘did something’ , Christian got straight in there, and many MBS plugins now work.
That MBS code is exactly how i have worked around this in my current iOS project.

Does it have to be the latest MBS, I’m a few versions back?

I’m bang up to date… a lot of work has gone in to support iOS and ARM
Probably need 20.5