Picture.Graphics

From Xojo Documentation

Read-Only Property (As Graphics )
GraphicsValue = aPicture.Graphics

Supported for all project types and targets.

The actual picture. The Graphics property gives you access to the methods of the Graphics class. Use it to draw in the picture. Use it when you need to draw into the picture. Create a new picture instance and then draw into it using the Graphics property.

Examples

This example creates a blank picture instance and then draws into it using the Graphics property. It assigns the picture to the backdrop property of a Canvas. A recommended alternative is to update the interface via drawing in the Canvas's Paint event instead.

Var p As New Picture (340, 280, 32)

p.Graphics.Bold = True
p.Graphics.Italic = True
p.Graphics.FontName = "Helvetica"
p.Graphics.FontSize = 18
p.Graphics.DrawingColor = &cff0000
p.Graphics.DrawString("Hello World", 10, 100)

Canvas1.Backdrop = p

You can also draw into an existing picture instance, e.g,

Var p As Picture
Var f As FolderItem
f = FolderItem.ShowOpenFileDialog("image/jpeg")
If f <> Nil Then
p = Picture.Open(f)
p.Graphics.Bold = True
p.Graphics.Italic = True
p.Graphics.FontName = "Helvetica"
p.Graphics.FontSize = 18
p.Graphics.DrawingColor = &cff0000
p.Graphics.DrawString("Hello World", 50, 230)
Canvas1.Backdrop = p
End If

See Also

Graphics