Class

# WebPicture

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

## Description

Creates a picture that can be used by the web browser, either for display or downloading.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                        | Type                               | Read-Only | Shared |
|---------------------------------------------|------------------------------------|-----------|--------|
| `Cached<webpicture.cached>`                 | `Boolean</api/data_types/boolean>` | ✓         |        |
| `FileName<webpicture.filename>`             | `String</api/data_types/string>`   |           |        |
| `ForceDownload<webpicture.forcedownload>`   | `Boolean</api/data_types/boolean>` |           |        |
| `MIMEType<webpicture.mimetype>`             | `String</api/data_types/string>`   |           |        |
| `Session<webpicture.session>`               | `WebSession</api/web/websession>`  |           |        |
| `URL<webpicture.url>`                       | `String</api/data_types/string>`   | ✓         |        |
| `UseCompression<webpicture.usecompression>` | `Boolean</api/data_types/boolean>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                      | Parameters                                                                                                                                | Returns                                  | Shared |
|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|--------|
| `BootstrapIcon<webpicture.bootstrapicon>` | name As `String</api/data_types/string>`, fillColor As `Color</api/data_types/color>` = &c000000FF                                        | WebPicture                               | ✓      |
| `Constructor<webpicture.constructor0>`    | data As `String</api/data_types/string>`, filename As `String</api/data_types/string>` = ""                                               |                                          |        |
| `Constructor<webpicture.constructor1>`    | file As `FolderItem</api/files/folderitem>`                                                                                               |                                          |        |
| `Constructor<webpicture.constructor2>`    | files() As `FolderItem</api/files/folderitem>`                                                                                            |                                          |        |
| `Constructor<webpicture.constructor3>`    | mb As `MemoryBlock</api/language/memoryblock>`, filename As `String</api/data_types/string>` = ""                                         |                                          |        |
| `Constructor<webpicture.constructor4>`    | source As `Picture</api/graphics/picture>`, format As `String</api/data_types/string>` = "public.png"                                     |                                          |        |
| `Constructor<webpicture.constructor5>`    | width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, files() As `FolderItem</api/files/folderitem>` |                                          |        |
| `Data<webpicture.data>`                   |                                                                                                                                           | `MemoryBlock</api/language/memoryblock>` |        |
|                                           | `Assigns</api/language/assigns>` value As `MemoryBlock</api/language/memoryblock>`                                                        |                                          |        |
| `Download<webpicture.download>`           |                                                                                                                                           | `Boolean</api/data_types/boolean>`       |        |
| `Height<webpicture.height>`               |                                                                                                                                           | `Integer</api/data_types/integer>`       |        |
| `Identifier<webpicture.identifier>`       |                                                                                                                                           | `String</api/data_types/string>`         |        |
| `Open<webpicture.open>`                   | file As `FolderItem</api/files/folderitem>`, inMemory As `Boolean</api/data_types/boolean>` = `True</api/language/true>`                  | `WebFile</api/web/webfile>`              | ✓      |
| `Width<webpicture.width>`                 |                                                                                                                                           | `Integer</api/data_types/integer>`       |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                | Parameters | Returns |
|-------------------------------------|------------|---------|
| `Downloaded<webpicture.downloaded>` |            |         |

## Property descriptions

<div id="webpicture.cached">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Cached

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

> Indicates whether or not the file is cached on the browser.
>
> This property is read-only.

<div id="webpicture.filename">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.FileName

**FileName** As `String</api/data_types/string>`

> The name of the file.
>
> Create a new file for downloading:
>
> ``` xojo
> TextFile = New WebFile ' TextFile is a property of the web page
> TextFile.MimeType = "text/plain"
> TextFile.ForceDownload = True ' If False, the browser may try to display the file instead of download it
> TextFile.FileName = "TextFile.txt"
>
> TextFile.Data = "Hello, world!"
>
> System.GotoURL(TextFile.URL) ' This causes the file to be downloaded
> ```

<div id="webpicture.forcedownload">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.ForceDownload

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

> Indicates whether the browser will always download the file instead of trying to display it (depending on the `MIMEType<webfile.mimetype>`). The default is `False</api/language/false>`.
>
> When `True</api/language/true>`, the browser will always download the file rather than try to display it. For example, most web browsers will try to display simple text files and many will display PDF files inline. Set ForceDownload to `True</api/language/true>` to instead ensure these types of files are downloaded instead.
>
> If you find that FireFox users can't download files, try using `WebControl.GotoURL<webcontrol.gotourl>` and pass `True</api/language/true>` for the *inNewWindow* parameter as well as having the user disable popup blockers.
>
> Create a new file for downloading:
>
> ``` xojo
> TextFile = New WebFile ' TextFile is a property of the web page
> TextFile.MimeType = "text/plain"
> TextFile.ForceDownload = True ' If False, the browser may try to display the file instead of download it
> TextFile.FileName = "TextFile.txt"
>
> TextFile.Data = "Hello, world!"
>
> System.GotoURL(TextFile.URL) ' This causes the file to be downloaded
> ```

<div id="webpicture.mimetype">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.MIMEType

**MIMEType** As `String</api/data_types/string>`

> This is the MIME type of the content. Browsers rely on this to determine what to do with the content. Setting `WebFile<webfile.forcedownload>` to `True</api/language/true>` will override the MIMEType. Defaults to "application/octet-stream".
>
> This example creates a text file to make available for download. You can put it on the Pressed event handler for a `WebButton</api/user_interface/web/webbutton>` so that the file is downloaded when the user clicks the button:
>
> ``` xojo
> TextFile = New WebFile ' TextFile is a property of the web page
> TextFile.MimeType = "text/plain"
> TextFile.ForceDownload = True ' If False, the browser may try to display the file instead of download it
> TextFile.FileName = "TextFile.txt"
>
> TextFile.Data = "Hello, world!"
>
> System.GotoURL(TextFile.URL) ' This causes the file to be downloaded
> ```

<div id="webpicture.session">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Session

**Session** As `WebSession</api/web/websession>`

> Session defaults to the current session which means it will only be accessible from that session.
>
> <div class="tip">
>
> <div class="title">
>
> Tip
>
> </div>
>
> Maintaining separate pictures for each session will use up more memory. To make a picture accessible to all sessions and thus be stored in memory only once, set the Session property to `Nil</api/language/nil>`.
>
> </div>

<div id="webpicture.url">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.URL

**URL** As `String</api/data_types/string>`

> The url to the file. Best used with `System<system.gotourl>`.
>
> This property is read-only.
>
> The Downloading example project uses `WebFile</api/web/webfile>`.URL to download the png test file that was opened in the `WebApplication</api/web/webapplication>` event. The code for the Static Download button is:
>
> ``` xojo
> If App.LogoFile <> Nil Then
>   System.GotoURL(App.LogoFile.URL)
> Else
>   MessageBox("Whoops, no logo file available")
> End If
> ```

<div id="webpicture.usecompression">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.UseCompression

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

> Determines if the web framework should compress a file before sending it to browsers that support gzip compression. The default value is `True</api/language/true>`.

## Method descriptions

<div id="webpicture.bootstrapicon">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.BootstrapIcon

**BootstrapIcon**(name As `String</api/data_types/string>`, fillColor As `Color</api/data_types/color>` = &c000000FF) As WebPicture

> Returns the icon whose name matches the *name* passed in the color specified by *fillColor*.
>
> This method is `shared</api/language/shared>`.
>
> You can find a complete list of icons [here](https://icons.getbootstrap.com/).

<div id="webpicture.constructor0">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Constructor

**Constructor**(Data As `String</api/data_types/string>`, Filename As `String</api/data_types/string>` = "")

> <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">WebPicture</span> from the passed string *data* using the specified *fileName*.

<div id="webpicture.constructor1">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Constructor

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

> Creates a <span class="title-ref">WebPicture</span> from the specified *file*.

<div id="webpicture.constructor2">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Constructor

**Constructor**(files() As `FolderItem</api/files/folderitem>`)

> Creates a <span class="title-ref">WebPicture</span> using the provided image *files* at various resolutions so that the <span class="title-ref">WebPicture</span> can draw appropriately on HiDPI screens.

<div id="webpicture.constructor3">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Constructor

**Constructor**(mb As `MemoryBlock</api/language/memoryblock>`, filename As `String</api/data_types/string>` = "")

> Creates a <span class="title-ref">WebPicture</span> from *mb* using the supplied *filename*.

<div id="webpicture.constructor4">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Constructor

**Constructor**(source As `Picture</api/graphics/picture>`, format As `String</api/data_types/string>` = "public.png")

> Creates a <span class="title-ref">WebPicture</span> from the passed *source* `Picture</api/graphics/picture>` in the format specified by *format*. *format* is one of the `Picture</api/graphics/picture>` format class constants and defaults to PNG. By supplying a different format than the original picture format of the file, you can convert the picture to a new format.

<div id="webpicture.constructor5">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Constructor

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

> Creates a new <span class="title-ref">WebPicture</span> based at the size indicated using the provided image *files* at various resolutions so that the <span class="title-ref">WebPicture</span> can draw appropriately on HiDPI screens.

<div id="webpicture.data">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Data

**Data** As `MemoryBlock</api/language/memoryblock>`

> Returns the data in the file.

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

**Data**(`Assigns</api/language/assigns>` value As `MemoryBlock</api/language/memoryblock>`)

> *value* is initially a 0-byte `MemoryBlock</api/language/memoryblock>`. You should create a new `MemoryBlock</api/language/memoryblock>` of the size that will be needed to store the data.
>
> You can also just assign a `String</api/data_types/string>` as the *value*.
>
> Create a new file for downloading:
>
> ``` xojo
> TextFile = New WebFile ' TextFile is a property of the web page
> TextFile.MimeType = "text/plain"
> TextFile.ForceDownload = True ' If False, the browser may try to display the file instead of download it
> TextFile.FileName = "TextFile.txt"
>
> TextFile.Data = "Hello, world!"
>
> System.GotoURL(TextFile.URL) ' This causes the file to be downloaded
> ```

<div id="webpicture.download">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Download

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

> Asks the browser to download the file. If this method returns true, it means that the request was sent to the browser, not that it was actually downloaded.
>
> This example creates a text file to make available for download. You can put it on the Pressed event handler for a `WebButton</api/user_interface/web/webbutton>` so that the file is downloaded when the user clicks the button:
>
> ``` xojo
> TextFile = New WebFile ' TextFile is a property of the web page
> TextFile.MimeType = "text/plain"
> TextFile.ForceDownload = True ' If False, the browser may try to display the file instead of download it
> TextFile.FileName = "TextFile.txt"
>
> TextFile.Data = "Hello, world!"
>
> If TextFile.Download Then ' This causes the file to be downloaded
>   ' Download requested
> End If
> ```

<div id="webpicture.height">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Height

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

> The height of the picture.

<div id="webpicture.identifier">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Identifier

**Identifier** As `String</api/data_types/string>`

> An identifier that is unique to this `WebFile</api/web/webfile>`.

<div id="webpicture.open">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Open

**Open**(file As `FolderItem</api/files/folderitem>`, inMemory As `Boolean</api/data_types/boolean>` = `True</api/language/true>`) As `WebFile</api/web/webfile>`

> Converts the passed `FolderItem</api/files/folderitem>` to a `WebFile</api/web/webfile>` that can be downloaded. The entire file is loaded in memory when *inMemory* is `True</api/language/true>` (the default). When *inMemory* is `False</api/language/false>`, the file is referenced directly from the disk and data is accessed in 64K chunks.
>
> This method is `shared</api/language/shared>`.
>
> Loading the entire file into memory means that the largest file that can be used is limited to the amount of free memory, up to a maximum of about 3GB or so.
>
> When the *inMemory* parameter is `False</api/language/false>`, the file is attempted to be loaded using 64K chunks. It is still possible, depending on the OS, for the entire file to be temporarily loaded into memory. This is not permanent as this memory will be released by the OS as part of its normal housecleaning.
>
> If you want to download an existing file on the server, you need to create a WebFile that points to it and save the reference. The best way to do this is to use a property of the `WebApplication</api/web/webapplication>` class. In the App.Opening event handler:
>
> ``` xojo
> Var f As FolderItem = New FolderItem("MyFile.txt", FolderItem.PathModes.Native) ' Get the file using a FolderItem
>
> If f <> Nil And f.Exists Then
>   ' Convert the FolderItem to a WebFile
>   App.MyFile = WebFile.Open(f) ' MyFile is a property on the App object
>   App.MyFile.ForceDownload = True
> End If
> ```
>
> Now in a `WebButton</api/user_interface/web/webbutton>` on a page, you can download this file like this:
>
> ``` xojo
> If App.MyFile <> Nil Then
>   System.GotoURL(App.MyFile.URL) ' Download the file
> End If
> ```

<div id="webpicture.width">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Width

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

> The width of the picture.

## Event descriptions

<div id="webpicture.downloaded">

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

</div>

<div class="rst-class">

forsearch

</div>

WebPicture.Downloaded

**Downloaded**

> Fires when the current browser requests the file.
>
> Use this event to display a message telling the user that the download is underway or perhaps to navigate them to a new page.
>
> After the download is underway, send the user back to the main web page:
>
> ``` xojo
> MainPage.Show
> ```

## Notes

<span class="title-ref">WebPicture</span> has an `Operator Convert</api/language/operators/operator_overloads/operator_convert>` method which will turn itself from/into a `Picture</api/graphics/picture>`. Both the following syntaxes are legal:

``` xojo
Var p As Picture = MyWebPicture
Var wp As WebPicture = p
```

Converting Picture to <span class="title-ref">WebPicture</span> gives you a PNG encoded image. For better performance avoid converting from <span class="title-ref">WebPicture</span> to Picture in your application and keep original Picture object.

Unlike `WebFile</api/web/webfile>`, <span class="title-ref">WebPicture</span> defaults the session property to the session which it was created in.

## Sample code

Convert a Picture, created at runtime to a <span class="title-ref">WebPicture</span> to display using a `WebImageViewer</api/user_interface/web/webimageviewer>`:

``` xojo
Var p As New Picture(100, 100, 32)
p.Graphics.DrawingColor = Color.Blue
p.Graphics.FillRectangle(10, 10, 50, 50)

Var wp As WebPicture = p
ImageViewer1.Picture = wp
```

## Compatibility

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

<div class="seealso">

`WebFile</api/web/webfile>` parent class; `WebHTMLViewer</api/user_interface/web/webhtmlviewer>`, `WebFile</api/web/webfile>`, `WebImageViewer</api/user_interface/web/webimageviewer>`, `Picture</api/graphics/picture>`

</div>
