Canvas in picture

In a canvas I load an image, then I write a text or draw something in paint, how can I copy everything on another picture so that I can use it for a pdf, to copy it to another camvas or more. I tried these two ways to view everything in another canvas but only the loaded image is displayed

dim p as Picture
canvas1.Refresh
1)
p=Canvas1.Backdrop
canvas2.Backdrop=p
2)
Canvas1.DrawInto (p.Graphics,0,0)
canvas2.Backdrop=p
which is the right solution?
Mario

When using the paint event, the content is not available via the Canvas’s Backdrop property. You should draw to a Picture object which you can make available via a property or method, then draw that to the Canvas in Paint.

thank you for the advice Anthony, i tried with this code but i get an error for every line
I have to write the character “O” in a previously calculated x and y coordinate
I load the image first
p=Picture.Open(f)
rem load ok if I use Canvas1.Backdrop = p i see the image on the canvas
p.Graphics.FontName = “Arial”
p.Graphics.DrawingColor = &cFF0000
p.Graphics.FontSize = 20
p.Graphics.Bold=true
p.Graphics.DrawText “O”,x,y
Canvas1.Backdrop=p
where am i wrong?
Mario

Try this:

pSource = Picture.Open(f)
Var p as New Picture( pSource.Width, pSource.Height )
p.graphics.DrawPicture( pSource, 0, 0 )
p.Graphics.FontName = "Arial"
p.Graphics.DrawingColor = &cFF0000
p.Graphics.FontSize = 20
p.Graphics.Bold = true
p.Graphics.DrawText( "O", x, y )
Canvas1.Backdrop = p

This is forum code, so I haven’t actually tested it.

I tried and it works fine, thank you very much Anthony
I only had to change p.DrawPicture(pSource, 0,0) with p.Graphics.DrawPicture(pSource, 0,0)

Mario

1 Like

Happy to help! I updated the response to include that fix. Please mark that post as the solution, so others can easily find it in the future.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.