Class

# Picture

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

A <span class="title-ref">Picture</span> object contains a <span class="title-ref">Picture</span> or an image.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                 | Type                                        | Read-Only | Shared |
|------------------------------------------------------|---------------------------------------------|-----------|--------|
| `Depth<picture.depth>`                               | `Integer</api/data_types/integer>`          | ✓         |        |
| `Graphics<picture.graphics>`                         | `Graphics</api/graphics/graphics>`          | ✓         |        |
| `Handle<picture.handle>`                             | `Ptr</api/data_types/additional_types/ptr>` | ✓         |        |
| `HasAlphaChannel<picture.hasalphachannel>`           | `Boolean</api/data_types/boolean>`          | ✓         |        |
| `Height<picture.height>`                             | `Integer</api/data_types/integer>`          | ✓         |        |
| `HorizontalResolution<picture.horizontalresolution>` | `Integer</api/data_types/integer>`          |           |        |
| `ImageCount<picture.imagecount>`                     | `Integer</api/data_types/integer>`          | ✓         |        |
| `MetaData<picture.metadata>`                         | `Dictionary</api/language/dictionary>`      |           |        |
| `Objects<picture.objects>`                           | `Group2D</api/graphics/group2d>`            |           |        |
| `RGBSurface<picture.rgbsurface>`                     | `RGBSurface</api/graphics/rgbsurface>`      | ✓         |        |
| `Type<picture.type>`                                 | `Types<picture.types>`                      | ✓         |        |
| `VerticalResolution<picture.verticalresolution>`     | `Integer</api/data_types/integer>`          |           |        |
| `Width<picture.width>`                               | `Integer</api/data_types/integer>`          | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                       | Parameters                                                                                                                                                                                                                                                                                                                                                                 | Returns                                     | Shared |
|------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|--------|
| `ApplyMask<picture.applymask>`                             | theMask As Picture                                                                                                                                                                                                                                                                                                                                                         |                                             |        |
| `BestRepresentation<picture.bestrepresentation>`           | width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, scale As `Double</api/data_types/double>`                                                                                                                                                                                                                                       | Picture                                     |        |
| `Constructor<picture.constructor0>`                        | width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                  |                                             |        |
| `Constructor<picture.constructor1>`                        | width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, bitmaps() As Picture                                                                                                                                                                                                                                                            |                                             |        |
| `CopyColorChannels<picture.copycolorchannels>`             |                                                                                                                                                                                                                                                                                                                                                                            | Picture                                     |        |
| `CopyMask<picture.copymask>`                               |                                                                                                                                                                                                                                                                                                                                                                            | Picture                                     |        |
| `CopyOSHandle<picture.copyoshandle>`                       | type As `HandleTypes<picture.handletypes>`                                                                                                                                                                                                                                                                                                                                 | `Ptr</api/data_types/additional_types/ptr>` |        |
|                                                            | width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, scale As `Double</api/data_types/double>`, type As `HandleTypes<picture.handletypes>`                                                                                                                                                                                           | `Ptr</api/data_types/additional_types/ptr>` |        |
| `FromData<picture.fromdata>`                               | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                                                                                                                           | Picture                                     | ✓      |
|                                                            | data As `String</api/data_types/string>`                                                                                                                                                                                                                                                                                                                                   | Picture                                     | ✓      |
| `FromHandle<picture.fromhandle>`                           | image As `Ptr</api/data_types/additional_types/ptr>`                                                                                                                                                                                                                                                                                                                       | Picture                                     | ✓      |
| `FromScaleFactor<picture.fromscalefactor>`                 | width As `Double</api/data_types/double>`, height As `Double</api/data_types/double>`, scaleFactor As `Double</api/data_types/double>`                                                                                                                                                                                                                                     | Picture                                     | ✓      |
| `ImageAt<picture.imageat>`                                 | index As `Integer</api/data_types/integer>`                                                                                                                                                                                                                                                                                                                                | Picture                                     |        |
| `IsExportFormatSupported<picture.isexportformatsupported>` | format As `Formats<picture.formats>`                                                                                                                                                                                                                                                                                                                                       | `Boolean</api/data_types/boolean>`          | ✓      |
| `IsImportFormatSupported<picture.isimportformatsupported>` | format As `Formats<picture.formats>`                                                                                                                                                                                                                                                                                                                                       | `Boolean</api/data_types/boolean>`          | ✓      |
| `Open<picture.open>`                                       | file As `FolderItem</api/files/folderitem>`                                                                                                                                                                                                                                                                                                                                | Picture                                     | ✓      |
| `OpenVector<picture.openvector>`                           | vectorFile As `FolderItem</api/files/folderitem>`                                                                                                                                                                                                                                                                                                                          | Picture                                     | ✓      |
| `Save<picture.save>`                                       | file As `FolderItem</api/files/folderitem>`, format As `Formats<picture.formats>`, quality As `Integer</api/data_types/integer>` = Picture.QualityDefault                                                                                                                                                                                                                  |                                             |        |
| `SaveToPhotos<picture.savetophotos>`                       | format As `Formats<picture.formats>`, quality As `Integer</api/data_types/integer>` = Picture.QualityDefault                                                                                                                                                                                                                                                               |                                             |        |
| `SystemImage<picture.systemimage>`                         | name As `String</api/data_types/string>`, size As `Double</api/data_types/double>`, weight As `Picture.SystemImageWeights<picture.systemimageweights>` = `Picture.SystemImageWeights.Regular<picture.systemimageweights>`, templateColor As `ColorGroup</api/graphics/colorgroup>` = `Nil</api/language/nil>`, fallbackTemplateImage As Picture = `Nil</api/language/nil>` | Picture                                     | ✓      |
|                                                            | name As `String</api/data_types/string>`, size As `Double</api/data_types/double>` = 24, templateColor As `ColorGroup</api/graphics/colorgroup>` = `Nil</api/language/nil>`, fallbackTemplateImage As Picture = `Nil</api/language/nil>`                                                                                                                                   | Picture                                     | ✓      |
| `ToData<picture.todata>`                                   | format As `Formats<picture.formats>`, jpegQuality As `Integer</api/data_types/integer>` = Picture.QualityDefault                                                                                                                                                                                                                                                           | `MemoryBlock</api/language/memoryblock>`    |        |

## Enumerations

<div id="picture.formats">

<div class="rst-class">

forsearch

</div>

</div>

Picture.Formats

### Formats

> The various <span class="title-ref">Picture</span> formats that are supported.
>
> | Enum | Supported Platforms                 |
> |------|-------------------------------------|
> | BMP  | Android, iOS, Linux, macOS, Windows |
> | GIF  | Android, macOS, Windows             |
> | HEIC | iOS                                 |
> | JPEG | Android, iOS, Linux, macOS, Windows |
> | PNG  | Android, iOS, Linux, macOS, Windows |
> | TIFF | iOS, Linux, macOS, Windows          |

<div id="picture.handletypes">

<div class="rst-class">

forsearch

</div>

</div>

Picture.HandleTypes

### HandleTypes

> OS handle types.
>
> | Enum            | Description                                                                                                                                                                                      |
> |-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
> | MacCGImage      | A CGImageRef that you are responsible for releasing with CFRelease. Supported on macOS GUI applications.                                                                                         |
> | WindowsBMP      | A 32-bit HBITMAP that you are responsible for releasing with DeleteObject. Supported in Windows GUI applications.                                                                                |
> | WindowsICON     | A 32-bit HICON that you are responsible for releasing with DeleteObject. Supported in Windows GUI applications.                                                                                  |
> | LinuxGdkPixbuf  | A 32-bit GdkPixbuf that you are responsible for releasing with g_object_unref. Supported in Linux GUI applications.                                                                              |
> | ConsoleGDImage  | A gdImagePtr that you are responsible for releasing with gdFree. This requires the use of the libgd library. Supported in console applications (all platforms).                                  |
> | MacNSImage      | A NSImage object that has been autoreleased, so an explicit release is not necessary. This is supported for all types of Pictures, including vector images. Supported on macOS GUI applications. |
> | iOSUIImage      | A UIImage object that has been autoreleased, so an explicit release is not necessary. Supported in iOS/iPadOS applications.                                                                      |
> | AndroidBitmap   | Supported for Android applications.                                                                                                                                                              |
> | AndroidDrawable | Supported for Android applications.                                                                                                                                                              |

<div id="picture.systemimageweights">

<div class="rst-class">

forsearch

</div>

</div>

Picture.SystemImageWeights

### SystemImageWeights

> The weight of a system image retrieve using SystemImage method.
>
> | Enum        | Description                         |
> |-------------|-------------------------------------|
> | Unspecified | An unspecified symbol image weight. |
> | UltraLight  | An ultralight weight.               |
> | Thin        | A thin weight.                      |
> | Light       | A light weight.                     |
> | Regular     | A regular weight.                   |
> | Medium      | A medium weight.                    |
> | Semibold    | A semibold weight.                  |
> | Bold        | A bold weight.                      |
> | Heavy       | A heavy weight.                     |
> | Black       | An ultra-heavy weight.              |

<div id="picture.types">

<div class="rst-class">

forsearch

</div>

</div>

Picture.Types

### Types

> The valid <span class="title-ref">Picture</span> types: Image, Vector, MutableBitmap, ImmutableBitmap
>
> | Enum            | Description                             |
> |-----------------|-----------------------------------------|
> | Image           | An Image for use with HiDPI displays.   |
> | Vector          | A Vector graphic.                       |
> | MutableBitmap   | A bitmap image that can be modified.    |
> | ImmutableBitmap | A bitmap image that cannot be modified. |

## Property descriptions

<div id="picture.depth">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Depth

**Depth** As `Integer</api/data_types/integer>`

> The bit depth of the picture.
>
> This property is read-only.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not supported for mobile projects.
>
> </div>

<div id="picture.graphics">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Graphics

**Graphics** As `Graphics</api/graphics/graphics>`

> The actual <span class="title-ref">Picture</span>. The Graphics property gives you access to the methods of the `Graphics</api/graphics/graphics>` class. Use it to draw in the <span class="title-ref">Picture</span>. Use it when you need to draw into the <span class="title-ref">Picture</span>. Create a new <span class="title-ref">Picture</span> instance and then draw into it using the Graphics property.
>
> This property is read-only.
>
> This example creates a blank <span class="title-ref">Picture</span> instance and then draws into it using the Graphics property. It assigns the <span class="title-ref">Picture</span> to the backdrop property of a Canvas. A recommended alternative is to update the interface via drawing in the Canvas's `Paint<desktopcanvas.paint>` event instead.
>
> ``` xojo
> 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.DrawText("Hello World", 10, 100)
>
> Canvas1.Backdrop = p
> ```
>
> You can also draw into an existing <span class="title-ref">Picture</span> instance. However, in this case, because loading a <span class="title-ref">picture</span> from a file creates a <span class="title-ref">picture</span> that is immutable (not changeable), you must create another <span class="title-ref">picture</span> and draw the <span class="title-ref">picture</span> you are opening from a file into that <span class="title-ref">picture</span> so that you can draw on top of it:
>
> ``` xojo
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If f <> Nil Then
>   Var p As Picture = Picture.Open(f)
>   Var mutablePicture As New Picture(p.Width, p.Height)
>
>   mutablePicture.Graphics.Bold = True
>   mutablePicture.Graphics.Italic = True
>   mutablePicture.Graphics.FontName = "Helvetica"
>   mutablePicture.Graphics.FontSize = 18
>   mutablePicture.Graphics.DrawingColor = &cff0000
>   mutablePicture.Graphics.DrawText("Hello World", 50, 230)
>   Canvas1.Backdrop = mutablePicture
> End If
> ```

<div id="picture.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

> Returns a `Ptr</api/data_types/additional_types/ptr>` to the underlying image. This property is for use with Declares on iOS only.
>
> The `Ptr</api/data_types/additional_types/ptr>` returned is a UIImage.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> A `Ptr</api/data_types/additional_types/ptr>` is only returned if the <span class="title-ref">picture</span> is a project item or was retrieved via `Picture.SystemImage<picture.systemimage>`.
>
> </div>
>
> This property is read-only.

<div id="picture.hasalphachannel">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.HasAlphaChannel

**HasAlphaChannel** As `Boolean</api/data_types/boolean>`

> `True</api/language/true>` if the <span class="title-ref">Picture</span> has an alpha channel.
>
> This property is read-only.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not supported for mobile projects.
>
> </div>
>
> A <span class="title-ref">Picture</span> that is created with the constructor that omits the *Depth* parameter has an alpha channel and old pictures can be converted to this format with the following code:
>
> ``` xojo
> 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
> ```

<div id="picture.height">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Height

**Height** As `Integer</api/data_types/integer>`

> The height (in pixels) of the <span class="title-ref">Picture</span>.
>
> This property is read-only.
>
> This example displays the width and height of the <span class="title-ref">Picture</span> that the user chose:
>
> ``` xojo
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If f <> Nil Then
>   Var pic As Picture = Picture.Open(f)
>
>   Label1.Text = pic.Width.ToString
>   Label2.Text = pic.Height.ToString
> End If
> ```

<div id="picture.horizontalresolution">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.HorizontalResolution

**HorizontalResolution** As `Integer</api/data_types/integer>`

> The horizontal resolution of the <span class="title-ref">Picture</span>.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not supported for Android.
>
> </div>
>
> The horizontal resolution is established when you use the Open shared method and written out when using the Save method. When creating a <span class="title-ref">Picture</span>, the default resolution is 72 (pixels).
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> To get the actual <span class="title-ref">Picture</span> resolution for an opened <span class="title-ref">Picture</span> file on Linux, gtk+ 2.32 or later is required.
>
> </div>
>
> This example gets the horizontal and vertical resolution of the <span class="title-ref">Picture</span> that was opened:
>
> ``` xojo
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If f <> Nil Then
>   Var pic As Picture = Picture.Open(f)
>
>   ImageWell1.Image = pic
>   Label1.Text = pic.HorizontalResolution.ToString
>   Label2.Text = pic.VerticalResolution.ToString
> End If
> ```

<div id="picture.imagecount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.ImageCount

**ImageCount** As `Integer</api/data_types/integer>`

> The number of indexed images in the <span class="title-ref">Picture</span>.
>
> This property is read-only.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not supported for Android.
>
> </div>
>
> This applies to image formats that can contain multiple images, such as TIFF.
>
> This example gets the number of indexed images in the <span class="title-ref">Picture</span>.
>
> ``` xojo
> Var width As Integer = 2000
> Var height As Integer = 2000
>
> ' creates new picture
> Var pic As New Picture(width, height, 32)
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If f <> Nil Then
>   pic = Picture.Open(f)
>   ImageWell1.Image = pic
>   Label1.Text = pic.ImageCount.ToString
> End If
> ```

<div id="picture.metadata">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.MetaData

**MetaData** As `Dictionary</api/language/dictionary>`

> Allows you to get and set the Exif data for the <span class="title-ref">picture</span>.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is currently supported for iOS only.
>
> </div>

<div id="picture.objects">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Objects

**Objects** As `Group2D</api/graphics/group2d>`

> A set of vector graphics associated with the <span class="title-ref">Picture</span> (optional).
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not supported for mobile projects.
>
> </div>
>
> Specify a depth of zero to create a <span class="title-ref">Picture</span> with no pixel map at all, but with a preinitialized Objects property. Use this option for creating vector graphics pictures via the set of Object2D subclasses.
>
> Create a vector image:
>
> ``` xojo
> Var vectorImage As New Picture(10, 10, 0)
> ```

<div id="picture.rgbsurface">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.RGBSurface

**RGBSurface** As `RGBSurface</api/graphics/rgbsurface>`

> Provides pixel-level access to the <span class="title-ref">Picture</span>'s bitmap.
>
> This property is read-only.
>
> Used only for pictures built with the <span class="title-ref">Picture</span> constructor with no pixel depth or only a depth of 16 or 32, otherwise it returns `Nil</api/language/nil>`. Returns an `RGBSurface</api/graphics/rgbsurface>` object. Calling RGBSurface is a computer-intensive process. Use it to access individual pixels of the <span class="title-ref">Picture</span> image. It is extremely fast — faster than accessing pixels through the `Graphics<picture.graphics>` property.

<div id="picture.type">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Type

**Type** As `Types<picture.types>`

> The Type of the <span class="title-ref">Picture</span>. This is set automatically based on how the <span class="title-ref">Picture</span> was created.
>
> This property is read-only.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not supported for Android.
>
> </div>
>
> Uses the Types Enumeration to specify the Type:
>
> - Image: An Image for use with HiDPI displays.
> - Vector: A Vector graphic.
> - MutableBitmap: A bitmap <span class="title-ref">Picture</span> that can be modified.
> - ImmutableBitmap: A bitmap <span class="title-ref">Picture</span> that cannot be modified.
>
> Pictures in the project, loaded from disk, received from drag and drop, or loaded from data will be loaded as Images (unless it's a Vector in which case it is loaded as Vector). This better preserves color spaces, loads multiple resolutions if the format supports it, and reduces memory usage.

<div id="picture.verticalresolution">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.VerticalResolution

**VerticalResolution** As `Integer</api/data_types/integer>`

> The vertical resolution of the <span class="title-ref">Picture</span>.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not supported for Android.
>
> </div>
>
> The vertical resolution is established when you use the Open shared method and written out when you use the Save method. When creating a <span class="title-ref">Picture</span>, the default resolution is 72 (pixels).
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> To get the actual <span class="title-ref">Picture</span> resolution for an opened <span class="title-ref">Picture</span> file on Linux, gtk+ 2.32 or later is required.
>
> </div>
>
> This example gets the horizontal and vertical resolution of the <span class="title-ref">Picture</span> that was opened.
>
> ``` xojo
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If f <> Nil Then
>   Var pic As Picture = Picture.Open(f)
>
>   ImageWell1.Image = pic
>   Label1.Text = pic.HorizontalResolution.ToString
>   Label2.Text = pic.VerticalResolution.ToString
> End If
> ```

<div id="picture.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Width

**Width** As `Integer</api/data_types/integer>`

> The width (in pixels) of the <span class="title-ref">Picture</span>.
>
> This property is read-only.
>
> This example displays the width and height of the <span class="title-ref">Picture</span> that the user chose.
>
> ``` xojo
> Var width As Integer = 2000
> Var height As Integer = 2000
>
> ' creates new picture
> Var pic As New Picture(width, height)
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If f <> Nil Then
>   pic = Picture.Open(f)
>   Label1.Text = pic.Width.ToString
>   Label2.Text = pic.Height.ToString
> End If
> ```

## Method descriptions

<div id="picture.applymask">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.ApplyMask

**ApplyMask**(theMask As Picture)

> When used on a <span class="title-ref">Picture</span> with an alpha channel, this overwrites the <span class="title-ref">Picture</span>'s alpha channel with the mask data. When used on a <span class="title-ref">Picture</span> with a mask, it overwrites the current mask with a copy of the mask passed in.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>

<div id="picture.bestrepresentation">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.BestRepresentation

**BestRepresentation**(width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, scale As `Double</api/data_types/double>`) As Picture

> Calculates which <span class="title-ref">Picture</span> is the best to use for drawing at the requested size.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>
>
> The algorithm iterates through the indexed images, first finding <span class="title-ref">Picture</span> with the closest number of pixels to the destination, preferring the next largest image if no exact match is found. If multiple pictures match, the <span class="title-ref">Picture</span> with the DPI closest to the destination scale is chosen. It is possible that this function returns Self.
>
> Raises an `InvalidArgumentException</api/exceptions/invalidargumentexception>` if width, height, or scale are less than or equal to zero.

<div id="picture.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Constructor

**Constructor**(width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`)

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.
>
> </div>
>
> Creates a <span class="title-ref">Picture</span> of the *width* and *height* specified.
>
> A <span class="title-ref">Picture</span> created with this constructor supports an alpha channel directly instead of requiring the use of masks.
>
> The *width* and *height* are in points.

<div id="picture.constructor1">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Constructor

**Constructor**(width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, bitmaps() As Picture)

> Creates a <span class="title-ref">Picture</span> of the size specified by the *width* and *height* from one or more Bitmap pictures.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>
>
> The *width* and *height* are in points. The *bitmaps* are copied upon creation. All bitmaps must have the same aspect ratio. A bitmap's DPI will be calculated from the point size and the bitmap's size in pixels. Pictures created using this constructor have their Type set to Types.Image.

<div id="picture.copycolorchannels">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.CopyColorChannels

**CopyColorChannels** As Picture

> Copies just the color information from a <span class="title-ref">Picture</span>.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>
>
> This method returns a clone of the color data in a <span class="title-ref">Picture</span> with a solid mask.
>
> The returned <span class="title-ref">Picture</span> object:
>
> - has the same dimensions, resolutions and scale factors as the original.
> - is a mutable bitmap
> - uses alpha channels instead of masks (i.e. HasAlphaChannel will be True)
> - is entirely opaque
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> An `UnsupportedOperationException</api/exceptions/unsupportedoperationexception>` will be raised when called on a vector or multi-representation image.
>
> </div>
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> An OutOfMemoryException will be raised if the <span class="title-ref">Picture</span> cannot be created.
>
> </div>
>
> Get the color channels from MyPic:
>
> ``` xojo
> Var colorChannels As Picture
>
> colorChannels = MyPic.CopyColorChannels
> ```

<div id="picture.copymask">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.CopyMask

**CopyMask** As Picture

> When used on a <span class="title-ref">Picture</span> with an alpha channel, this takes the image's alpha channel and creates the equivalent mask. If used on a <span class="title-ref">Picture</span> with a mask, it returns a copy of the current mask. In neither case does it alter the original image and the copied mask is not updated when any drawing happens on the original <span class="title-ref">Picture</span>.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>

<div id="picture.copyoshandle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.CopyOSHandle

**CopyOSHandle**(type As `Picture.HandleTypes<picture.handletypes>`) As `Ptr</api/data_types/additional_types/ptr>`

> Returns a platform-specific image handle.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>
>
> The following code gets the CGImageRef from the <span class="title-ref">Picture</span> and properly releases it.
>
> ``` xojo
> Declare Sub CFRelease Lib "CoreFoundation" (obj As Ptr)
>
> Var pict As New Picture(100, 100, 32)
> Var cgImage As Ptr = pict.CopyOSHandle(Picture.HandleTypes.MacCGImage)
>
> ' Do something with the 'cgImage' object
> CFRelease(cgImage)
> ```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

Picture.CopyOSHandle

**CopyOSHandle**(width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, scale As `Double</api/data_types/double>`, type As `HandleTypes<picture.handletypes>`) As `Ptr</api/data_types/additional_types/ptr>`

> Returns a platform-specific image handle that is the best match for drawing at the given resolution, using the same logic as `BestRepresentation<picture.bestrepresentation>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>

<div id="picture.imageat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.ImageAt

**ImageAt**(index As `Integer</api/data_types/integer>`) As <span class="title-ref">Picture</span>

> Returns the image in the <span class="title-ref">picture</span> specified by the passed *index*.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not supported for Android.
>
> </div>
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> The individual pictures aren't necessarily stored/returned in ascending scalefactor order. Do not rely on a particular order for the pictures.
>
> </div>
>
> This example gets the image referenced by the passed index and displays it in the `ImageViewer</api/user_interface/desktop/desktopimageviewer>`:
>
> ``` xojo
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If f <> Nil Then
>   Var pic As Picture = Picture.Open(f)
>   ImageViewer1.Image = pic.ImageAt(0)
> End If
> ```
>
> If you have an Image Set with multiple images for HiDPI and want to split out each of the pictures it contains, you can do so like this:
>
> ``` xojo
> Var g As Graphics
> Var p, pics() As Picture
>
> ' Break the Image into its component pictures
> ' Also copy the horizontal/vertical resolution and scale factors
> ' so that the pictures draw properly when used later.
> For i As Integer = 0 To MyImageSet.ImageCount - 1
>   p = New Picture(MyImageSet.ImageAt(i).Width, ImageAt(i).Height)
>   p.HorizontalResolution = MyImageSet.ImageAt(i).HorizontalResolution
>   p.VerticalResolution = MyImageSet.ImageAt(i).VerticalResolution
>   pics.Add(p)
>   g = p.Graphics
>   g.ScaleX = p.HorizontalResolution / 72
>   g.ScaleY = p.VerticalResolution / 72
>   g.DrawPicture(MyImageSet.ImageAt(i), 0, 0)
> Next
> ```
>
> If you later modify the pictures in the array and want to recreate it as an image, you can do so using the constructor like this:
>
> ``` xojo
> ' Recreate the image from the component pictures
> p = New Picture(MyImageSet.Width, MyImageSet.Height, pics)
> ```

<div id="picture.fromdata">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.FromData

**FromData**(data As `MemoryBlock</api/language/memoryblock>`) As Picture

> Obtains a <span class="title-ref">Picture</span> that is stored in a `MemoryBlock</api/language/memoryblock>` and returns a <span class="title-ref">Picture</span>.
>
> This method is `shared</api/language/shared>`.
>
> This example uses `ToData<picture.todata>` to convert an image in an `ImageViewer</api/user_interface/desktop/desktopimageviewer>` into a `MemoryBlock</api/language/memoryblock>` and then uses FromData to display the image:
>
> ``` xojo
> Var mb As MemoryBlock
>
> If ProductImageViewer.Image <> Nil Then
>   ' Get the image data
>   mb = ProductImageViewer.Image.ToData(Picture.Formats.JPEG, Picture.QualityHigh) 
>   ' convert the MemoryBlock back into an image
>   ImageViewer1.Image = Picture.FromData(mb) 
> End If
> ```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

Picture.FromData

**FromData**(data As `String</api/data_types/string>`) As Picture

> Obtains a <span class="title-ref">Picture</span> that is stored in the *data* passed and returns a <span class="title-ref">Picture</span>.
>
> This method is `shared</api/language/shared>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This signature is supported for Android only.
>
> </div>

<div id="picture.fromhandle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.FromHandle

**FromHandle**(image As `Ptr</api/data_types/additional_types/ptr>`) As Picture

> Returns a <span class="title-ref">Picture</span> from an OS handle
>
> This method is `shared</api/language/shared>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is supported for iOS only.
>
> </div>

<div id="picture.fromscalefactor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.FromScaleFactor

**FromScaleFactor**(width As `Double</api/data_types/double>`, height As `Double</api/data_types/double>`, scaleFactor As `Double</api/data_types/double>`) As Picture

> Creates a new <span class="title-ref">Picture</span> with the specified *width* and *height* (rounded to the nearest pixel), adjusted for a given scale factor.
>
> This method is `shared</api/language/shared>`.

<div id="picture.isexportformatsupported">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.IsExportFormatSupported

**IsExportFormatSupported**(format As `Formats<picture.formats>`) As `Boolean</api/data_types/boolean>`

> Returns `True</api/language/true>` if the passed format is supported for export.
>
> This method is `shared</api/language/shared>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is supported for desktop and console projects only.
>
> </div>
>
> This example checks to see that the format is supported for export prior to calling it:
>
> ``` xojo
> Var imageData As String
> Var bs As BinaryStream
> Var f As FolderItem
>
> If ImageWell1.Image <> Nil Then
>   ' Get a temporary file to save the image to
>   If Picture.IsExportFormatSupported(Picture.Formats.JPEG) Then
>     f = SpecialFolder.Temporary.Child("TempImage.jpg")
>
>     ' Save the image out to the file
>     ImageWell1.Image.Save(f, Picture.Formats.JPEG)
>   End If
>
>   ' Open the file as a BinaryStream and read the data in
>   bs = BinaryStream.Open(f, False)
>
>   If bs <> Nil Then
>     imageData = bs.Read(bs.Length)
>     bs.Close
>   End If
>
>   ' delete the temporary file if it exists
>   If f.Exists Then
>     f.Delete
>   End If
> End If
> ```

<div id="picture.isimportformatsupported">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.IsImportFormatSupported

**IsImportFormatSupported**(format As `Formats<picture.formats>`) As `Boolean</api/data_types/boolean>`

> Returns `True</api/language/true>` if the passed format is supported for import.
>
> This method is `shared</api/language/shared>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is supported for desktop and console projects only.
>
> </div>
>
> BMP, GIF and TIFF formats are not supported for Console apps.
>
> This example checks to see if a format is supported for import prior to calling it:
>
> ``` xojo
> Var width As Integer = 2000
> Var height As Integer = 2000
>
> ' creates new picture
> Var pic As New Picture(width, height)
>
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/jpeg")
>
> If Picture.IsImportFormatSupported(Picture.Formats.JPEG) Then
>   If f <> Nil Then
>     pic = Picture.Open(f)
>     ImageWell1.Image = pic
>   End If
> End If
> ```

<div id="picture.open">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Open

**Open**(file As `FolderItem</api/files/folderitem>`) As Picture

> Opens the passed `FolderItem</api/files/folderitem>` to be read as a <span class="title-ref">Picture</span>. Returns a <span class="title-ref">Picture</span> on success. If the FolderItem passed is nil, a `NilObjectException</api/exceptions/nilobjectexception>` is raised. If <span class="title-ref">Picture</span>.Open fails for any other reason, `Nil</api/language/nil>` is returned with no other error information.
>
> This method is `shared</api/language/shared>`.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> Pictures opened with this method are immutable.
>
> All supported `Picture.Formats<picture.formats>` can also be opened. Depending on the operating system also others.
>
> </div>
>
> The following example prompts you to select a file and then opens it and displays it in an `DesktopImageViewer</api/user_interface/desktop/desktopimageviewer>`:
>
> ``` xojo
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("")
>
> If f <> Nil And f.Exists Then
>   ImageWell1.Image = Picture.Open(f)
> End If
> ```

<div id="picture.openvector">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.OpenVector

**OpenVector**(vectorFile As `FolderItem</api/files/folderitem>`) As Picture

> Opens the passed FolderItem to be read as a vector <span class="title-ref">Picture</span>.
>
> This method is `shared</api/language/shared>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is supported for desktop and console projects only.
>
> </div>
>
> It will do its best to convert a PICT file (on macOS) or an .emf file (Windows) to a <span class="title-ref">Picture</span> composed of `Object2D</api/graphics/object2d>` objects. The original file may contain elements that do not have an equivalent `Object2D</api/graphics/object2d>` object. This method will do its best to map these objects, but there may be some loss of information, depending on the characteristics of the original file. PICTs support unrotated Rectangles, Lines, Ellipses, RoundRects, Polygons, Text, Pixmaps, and Arcs.
>
> .emf files support unrotated Rectangles, Lines, Ellipses, RoundRects, Polygons, Text, Pixmaps and Arcs.
>
> .emf files are displayed as actual size. For the most part this is huge; you probably will want to scale them down before viewing (pic1.objects.scale = scalingFactor). We find that a scale factor of 0.045 is a good value.
>
> The following example opens an ancient PICT file as a <span class="title-ref">Picture</span>. The image/x-pict file type has been added using the File Types Editor.
>
> ``` xojo
> Var f As FolderItem = FolderItem.ShowOpenFileDialog("image/x-pict")
> Var p As Picture = Picture.OpenVector(f)
>
> If p <> Nil Then
>   MessageBox(p.ImageCount.ToString)
> Else
>   MessageBox("Open failed!")
> End If
> ```

<div id="picture.save">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.Save

**Save**(file As `FolderItem</api/files/folderitem>`, format As `Formats<picture.formats>`, quality As `Integer</api/data_types/integer>` = Picture.QualityDefault)

> Saves the <span class="title-ref">Picture</span> in file specified by *file*, using the file format specified by *format*. For the list of available formats, see `Formats<picture.formats>`.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> Only JPEG and PNG are supported in `console applications</api/console/consoleapplication>`
>
> </div>
>
> If the `FolderItem</api/files/folderitem>` exists, then it will be overwritten by the new <span class="title-ref">Picture</span> file.
>
> If you are using the JPEG format, then there is an optional parameter for the quality of the JPEG. You specify the quality using the following class constants. Introduced 2010r5
>
> | Constant       | Value |
> |----------------|-------|
> | QualityDefault | -1    |
> | QualityMaximum | 100   |
> | QualityHigh    | 80    |
> | QualityMedium  | 50    |
> | QualityLow     | 25    |
> | QualityMinimum | 0     |
>
> The following example saves the contents of an `DesktopImageViewer</api/user_interface/desktop/desktopimageviewer>` to a temporary file on disk and then reads it into a `BinaryStream</api/files/binarystream>` for storage in a database. The property f as `FolderItem</api/files/folderitem>` is a property of the window.
>
> ``` xojo
> Var imageData As String
> Var bs As BinaryStream
> Var f As FolderItem
>
> If ImageWell1.Image <> Nil Then
>   ' Get a temporary file to save the image to
>   If Picture.IsExportFormatSupported(Picture.Formats.JPEG) Then
>     f = SpecialFolder.Temporary.Child("TempImage.jpg")
>
>     ' Save the image out to the file
>     ImageWell1.Image.Save(f, Picture.Formats.JPEG)
>   End If
>
>   ' Open the file as a BinaryStream and read the data in
>   bs = BinaryStream.Open(f, False)
>
>   If bs <> Nil Then
>     imageData = bs.Read(bs.Length)
>     bs.Close
>   End If
>
>   ' delete the temporary file if it exists
>   If f.Exists Then
>     f.Delete
>   End If
> End If
> ```

<div id="picture.savetophotos">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.SaveToPhotos

**SaveToPhotos**(format As `Formats<picture.formats>`, quality As `Integer</api/data_types/integer>` = Picture.QualityDefault)

> Saves the <span class="title-ref">Picture</span> to the user album, using the *format* and *quality* passed.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is currently supported for iOS only.
>
> </div>

<div id="picture.systemimage">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.SystemImage

**SystemImage**(name As `String</api/data_types/string>`, size As `Double</api/data_types/double>`, weight As `SystemImageWeights<picture.systemimageweights>` = `Picture.SystemImageWeights.Regular<picture.systemimageweights>`, templateColor As `ColorGroup</api/graphics/colorgroup>` = `Nil</api/language/nil>`, fallbackTemplateImage As <span class="title-ref">Picture</span> = `Nil</api/language/nil>`) As <span class="title-ref">Picture</span>

> This method retrieves an image based upon the parameters passed.
>
> On iOS these images come from iOS itself and are called *SF Symbols*. There are over more than 1500 system symbol images available. To browse the available symbol images, use the [Apple SF Symbols](https://developer.apple.com/design/resources/) viewer app.
>
> This method is `shared</api/language/shared>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is only supported for iOS.
>
> </div>
>
> This example returns the image named "moon" at a size of 50 and then draws it into a `Graphics</api/graphics/graphics>` object:
>
> ``` xojo
> Var moon As Picture = Picture.SystemImage("moon", 50)
> g.DrawPicture(moon, 0, 0)
> ```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

Picture.SystemImage

**SystemImage**(name As `String</api/data_types/string>`, size As `Double</api/data_types/double>` = 24, templateColor As `ColorGroup</api/graphics/colorgroup>` = `Nil</api/language/nil>`, fallbackTemplateImage As <span class="title-ref">Picture</span> = `Nil</api/language/nil>`) As <span class="title-ref">Picture</span>

> This method retrieves an image based upon the parameters passed.
>
> On Android, the image comes from a library of images built-in to the Xojo Android framework. There are over [more than 2000 images available](https://pictogrammers.com/library/mdi/).
>
> This method is `shared</api/language/shared>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is only supported for Android.
>
> </div>
>
> This example returns the image named "moon-full" at a size of 48 and then draws it into a `Graphics</api/graphics/graphics>` object:
>
> ``` xojo
> Var moon As Picture = Picture.SystemImage("moon-full", 48)
> g.DrawPicture(moon, 0, 0)
> ```

<div id="picture.todata">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Picture.ToData

**ToData**(format As `Formats<picture.formats>`, jpegQuality As `Integer</api/data_types/integer>` = Picture.QualityDefault) As `MemoryBlock</api/language/memoryblock>`

> Converts the <span class="title-ref">Picture</span> to a `MemoryBlock</api/language/memoryblock>`.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> Console applications only support JPEG and PNG image types.
>
> </div>
>
> If you are using the JPEG format, then there is an optional parameter for the quality of the JPEG. You specify the quality using the following class constants instead of the literal values.
>
> | Constant       | Value |
> |----------------|-------|
> | QualityDefault | -1    |
> | QualityMaximum | 100   |
> | QualityHigh    | 80    |
> | QualityMedium  | 50    |
> | QualityLow     | 25    |
> | QualityMinimum | 0     |
>
> This example uses ToData to convert an image in an `DesktopImageViewer</api/user_interface/desktop/desktopimageviewer>` into a `MemoryBlock</api/language/memoryblock>`:
>
> ``` xojo
> Var mb As MemoryBlock
>
> If ProductImageViewer.Image <> Nil Then
>   ' Get the image data
>   mb = ProductImageViewer.Image.ToData(Picture.Formats.JPEG, Picture.QualityHigh) 
>   ' convert the MemoryBlock back into an image
>   ImageViewer1.Image = Picture.FromData(mb) 
> End If
> ```

## Notes

<div class="note">

<div class="title">

Note

</div>

Console applications only support JPEG and PNG image types.

</div>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Image Sets and HiDPI

When adding Pictures to your projects, you create `Image Set Editor</getting_started/using_the_ide/image_set_editor>` which can contain the <span class="title-ref">Picture</span> at various sizes for use with HiDPI displays.

Also refer to `HiDPI Support</topics/graphics/hidpi_support>` for important additional information.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Support for transparency

Picture objects support alpha channels (transparency) directly, without the need for a mask.

Support for the alpha channel is now built into the color functions: `Color.RGB<color.rgb>`, `Color.HSV<color.hsv>`, `Color.CMY<color.cmy>`, and `&c</api/language/literals/c>`. These functions have an optional fourth parameter that specifies the degree of transparency of the color. Here are the modified functions:

| Function                       | Parameters                                                                                                                                                                            |
|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `Color.RGB<color.rgb>`         | *red* as `Integer</api/data_types/integer>`, green As `Integer</api/data_types/integer>`, blue As `Integer</api/data_types/integer>`, alpha As `Integer</api/data_types/integer>` = 0 |
| `Color.HSV<color.hsv>`         | *hue* as `Double</api/data_types/double>`, saturation As `Double</api/data_types/double>`, value As `Double</api/data_types/double>`, alpha As `Integer</api/data_types/integer>` = 0 |
| `Color.CMY<color.cmy>`         | *cyan* as `Double</api/data_types/double>`, magenta As `Double</api/data_types/double>`, yellow As `Double</api/data_types/double>`, alpha As `Integer</api/data_types/integer>` = 0  |
| `&c</api/language/literals/c>` | *RRGGBBAA*, where the hex digits specify the amounts of red, green, blue, and transparency in the color. For the transparency parameter, 00 is opaque and FF is fully transparent.    |

In the <span class="title-ref">Picture</span> class, support for alpha channels means that the use of masks is no longer required. This streamlines the process and reduces memory support. To take advantage of this feature, you can create new <span class="title-ref">Picture</span> objects with alpha channel support and convert “old” <span class="title-ref">Picture</span> objects to those with alpha channels.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Updating pictures with masks

Pictures loaded from disk, databases, project files, or <span class="title-ref">Picture</span>.FromData continue to return pictures with masks. This is required for legacy compatibility, but masked Pictures can be converted to a <span class="title-ref">Picture</span> with an alpha channel with the following code:

``` xojo
Function ConvertToAlphaPicture(input As Picture) As Picture
  If input.HasAlphaChannel Then Return input

  Var result As New Picture(input.Width, input.Height)

  result.HorizontalResolution = input.HorizontalResolution
  result.VerticalResolution = input.VerticalResolution
  result.Graphics.DrawPicture(input, 0, 0)
  Return result
End Function
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### HasAlphaChannel property

``` xojo
HasAlphaChannel As Boolean
```

This property indicates whether or not the <span class="title-ref">Picture</span> has an alpha channel. For Pictures using masks, this returns `False</api/language/false>`.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### CopyMask method

``` xojo
CopyMask As Picture
```

When used on a <span class="title-ref">Picture</span> with an alpha channel, this takes the image's alpha channel and creates the equivalent mask. If used on a <span class="title-ref">Picture</span> with a mask, it returns a copy of the current mask. In neither case does it alter the original image and the copied mask is not updated when any drawing happens on the original <span class="title-ref">Picture</span>.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### ApplyMask method

``` xojo
ApplyMask(theMask As Picture)
```

When used on a <span class="title-ref">Picture</span> with an alpha channel, this overwrites the <span class="title-ref">Picture</span>'s alpha channel with the mask data. When used on a <span class="title-ref">Picture</span> with a mask, it overwrites the current mask with a copy of the mask passed in.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Other alpha channel notes

`Pixel</api/graphics/rgbsurface>` and `RGBSurface</api/graphics/rgbsurface>` have been updated to properly support alpha channels by taking them into account when rendering them. Additionally, `Pixel</api/graphics/rgbsurface>` properly reports back alpha channel information, if available.

Pictures with alpha channels cannot also use masks. Trying to do so will raise an `UnsupportedOperationException</api/exceptions/unsupportedoperationexception>` at runtime. Reading this value always returns `Nil</api/language/nil>` for pictures with alpha channels. For pictures without alpha channels, the mask functionality continues to work normally.

On macOS and Linux, Pictures are stored internally with their alpha channels premultiplied into the color channels. Since premultiplication is a lossy operation, the color you draw may not be exactly what you get out when inspecting it with an `RGBSurface</api/graphics/rgbsurface>`. For example, drawing a `&cFF00EECC` rectangle will result in a different color if read from that pixel using `RGBSurface</api/graphics/rgbsurface>`.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Plugin support

The color type has changed from being XRGB to ARGB. If you previously put garbage into the first byte, this is going to cause problems now that the framework uses this to store the alpha component.

On macOS, a <span class="title-ref">Picture</span> with an alpha channel is represented internally as a premultiplied ARGB buffer wrapped by a `CGBitmapContext`. This buffer can be accessed the same way as for masked images: `REALLockPictureDescription` and then `CGBitmapContextGetData`.

On Windows, a <span class="title-ref">Picture</span> with an alpha channel is represented internally as a premultiplied 32-bit BGRA buffer. This buffer can be accessed the same way as for masked images: `REALLockPictureDescription` and the raw bytes are returned in the data field.

On Linux, a <span class="title-ref">Picture</span> with an alpha channel is represented internally as a 32-bit premultiplied ARGB buffer wrapped by a `cairo_t`. This buffer can be accessed the same way as for masked images: `REALLockPictureDescription` and then `cairo_image_surface_get_data( cairo_get_target( cairo_t * ) )`.

On console and web apps, a <span class="title-ref">Picture</span> with an alpha channel is represented internally as a 32-bit ARGB buffer wrapped by a gdImagePtr.

<div class="note">

<div class="title">

Note

</div>

The ARGB buffer is NOT premultiplied, and the maximum alpha value is 127 instead of 255. This buffer can be accessed the same way as for masked images: `REALLockPictureDescription` with `pictureGDPtr` (this will give you the raw buffer with an 11 byte header).

</div>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Creating a <span class="title-ref">Picture</span>

A <span class="title-ref">Picture</span> object is created by adding a <span class="title-ref">Picture</span> to the project, by calling the <span class="title-ref">Picture</span> constructor or the `OpenVector<picture.openvector>` method of a `FolderItem</api/files/folderitem>` object. When you use the `New</api/language/new>` operator, you must use the constructor. If you use the `New</api/language/new>` operator but run out of memory, an `OutOfMemoryException</api/exceptions/outofmemoryexception>` error will be raised.

Here is an example on how to create a <span class="title-ref">Picture</span> and handle the `OutOfMemoryException</api/exceptions/outofmemoryexception>` exception:

``` xojo
' 2000 x 2000 Pixel works, but 20000 x 20000 Pixel will raise exception
Var width  As Integer = 2000 
Var height As Integer = 2000

' creates new picture 
Var pic As New Picture(width, height)

' fill with red
pic.Graphics.DrawingColor = &cFF0000
pic.Graphics.FillRectangle(0, 0, 100, 100)

' and show picture in a window/canvas backdrop
Self.Backdrop = pic

Exception o As OutOfMemoryException
  MessageBox("Picture dimensions too big." + EndOfLine + EndOfLine + Integer(width * height * 4 / 1024 / 1024).ToString + " MB")
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Cross-platform formats

PNG, JPEG and BMP formats are cross-platform.

Unrecognized formats or formats not supported for the built target will result in an `UnsupportedFormatException</api/exceptions/unsupportedformatexception>`. The Message property of the exception will contain additional information about what went wrong.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Jpeg quality constants

If you are using the JPEG format, then there is an optional parameter for the quality of the JPEG. You specify the quality using the following class constants.

| Constant       | Value |
|----------------|-------|
| QualityDefault | 1     |
| QualityHigh    | 80    |
| QualityLow     | 25    |
| QualityMaximum | 100   |
| QualityMedium  | 50    |
| QualityMinimum | 0     |

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `RGBSurface</api/graphics/rgbsurface>` object; `Graphics</api/graphics/graphics>` class.

</div>
