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

From Xojo Documentation
Jump to: navigation, search
Constructor
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.


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, 1, 2, 4, 8, 16, or 32. 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.


NOTE: Cocoa always uses 32-bit picture depth regardless of the value you specify for Depth.  



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 ModernizePicture(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


Examples

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 mirror the content that is drawn into a Canvas in its Paint event.

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

Variants
Actions
Main
Documentation
Community
Toolbox
Help