Canvas scroll save

A canvas holds an image bigger that its size. (so the canvas has scroll, and zoom)
The user may draw/add into graphics of the canvas.

Is there a way to save or copy the whole picture of the canvas? The canvas1.DrawInto only copy the visible portion of the image.

I know (too late) that I should have used a pictBuffer but I didn’t, so to avoid to re-code all, is there a way to get the whole image? In some place should Xojo keep the whole image, no?

Maybe the question should be clear as ¿can be the whole Canvas Graphics layer saved?

There is no way to do this without maintaining a copy of the image in-memory as a property, or redrawing to a Picture using a method when you wish to save.

Then the question should be a suggestion to Xojo: why don’t add a parameter to DrawInto that indicates “the whole” or the “visible” (as now).

A canvas really is meant more as a display component rather than storage, and it should be trivial for you to adapt your Paint event code to a function that returns a Picture.

Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint Var pRet as Picture = myDrawMethod( g.Width, g.Height ) g.DrawPicture( pRet, 0, 0 ) End Sub

[code]Private Function myDrawMethod(bufferWidth as Double, bufferHeight as Double) as Picture
Var p as new Picture( bufferWidth, bufferHeight )
Var g as Graphics = p.Graphics

g.DrawingColor = &cFF0000
g.FillRectangle( 0, 0, g.Width, g.Height )

Return p
End Function

Of course there’s a lot more that you’ll need to account for as you progress, but that’ll get you started.

u can use a full size picture as permanent property and then
Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
g.DrawPicture( MyPicture, OffsetX, OffsetY )
End Sub

or you need to store any draw step (into a list) and paint it on the fly into any graphics object
but it will be slower the more you had paint.

Thanks these will be my starter points.