Picture.Constructor(width as Integer, height as Integer, Depth as Integer)

From Xojo Documentation
Jump to: navigation, search
Picture.Constructor(width as Integer, height as Integer, Depth as Integer)

Creates a Picture instance using the passed width, height, and depth parameters. Both Width and Height must be in the range 1 - 32767, otherwise an OutOfBoundsException will be raised.


Width and Height specify the size of the picture and are in pixels. Depth specifies the pixel depth of the picture and can be . 0, 24 or 32. Creating Pictures with an invalid bit depth raises an InvalidArgumentException (note: 32-bit pictures are always created, but you are allowed to specify 24-bit depth as a parameter to minimize breaking of existing code. Any other supplied bit depth raises the exception).

If you specify a depth of zero, a picture with no pixel map at all is created, but with a preinitialized Objects property. Use this option for creating vector graphics pictures via the set of Object2D subclasses.

Updating "old" Pictures

Pictures loaded from disk, databases, project files, or Picture.FromData continue to return pictures with masks. This is required for legacy compatibility, but masked Pictures can be converted to a Picture with an alpha channel with the following code:

Function ConvertToAlphaPicture(input As Picture) As Picture
If input.hasAlphaChannel Then Return input

Dim result As New Picture(input.Width, input.Height)
result.Graphics.DrawPicture(input, 0, 0)
Return result
End Function


The following creates a new Picture instance.

Dim width As Integer = 2000
Dim height As Integer = 2000

// creates new picture
Dim pic As New Picture(width, height, 32)

This constructor creates a Picture object that will matches the size of a Canvas:

p = New Picture(Canvas1.Width, Canvas1.Height, 32)
Personal tools

Starting Out
Dig Deeper
More Help