Constructor
Picture.Constructor(width As Integer, height As Integer, depth As Integer)
Warning
This item was deprecated in version 2020r2. Please use Picture(width As Integer, height As Integer) as a replacement.
Description
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.
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.
Converting from a mask to an alpha channel
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
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 width As Integer = 2000
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:
p = New Picture(Canvas1.Width, Canvas1.Height, 32)
Compatibility
All project types on all supported operating systems.