Picture.Constructor(width as Integer, height as Integer, Depth as Integer)
From Xojo Documentation
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.
Exceptions
Exception | Reason |
---|---|
InvalidArgumentException | Raised if a bit depth other than 0, 24 or 32 is used. Note that although 24-bit can be specified for code compatibility, a 32-bit picture is what actually gets created. |
OutOfBoundsException | Raised if Width and Height are outside the range 1 - 32767. |
OutOfMemoryException | Raised if there is not enough memory to create the picture, which can happen with 32-bit apps. |
Notes
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:
If input.hasAlphaChannel Then Return input
Var result As New Picture(input.Width, input.Height)
result.Graphics.DrawPicture(input, 0, 0)
Return result
End Function
Sample Code
The following creates a new Picture instance.
Var height As Integer = 2000
// Creates new picture
Var pic As New Picture(width, height, 32)
This constructor creates a Picture object that will matches the size of a Canvas: