WebImageViewer

From Xojo Documentation

Class (inherits from WebUIControl)


New in 2020r1

Displays a picture either from a project item, one assigned at runtime, SVG data or via a URL.

Events
Closed Hidden Pressed
ContextualMenuSelected Opening Shown


Properties
AlignHorizontal LockHorizontal fa-lock-32.png Style
AlignVertical LockLeft fa-lock-32.png TabIndex
ContextualMenu LockRight fa-lock-32.png Tooltip
ControlID fa-lock-32.png LockVertical fa-lock-32.png Top
Enabled Name fa-lock-32.png URL
Height Page fa-lock-32.png Visible
Indicator Parent fa-lock-32.png Width
Left Picture
LockBottom fa-lock-32.png SVGData


Methods
Close GotoURL UpdateBrowser
ExecuteJavaScript SetFocus

Notes

The WebImageViewer appears as a rectangular area on a WebPage in the Web Page Layout Editor. If no image is assigned, then a placeholder icon is displayed in the center. If an image from your project is specified, it is shown in both the Layout Editor and the built application. The WebPage Layout Editor cannot render SVG data in the IDE.

Manipulating The Picture

You cannot directly manipulate the Picture property as it is actually a WebPicture, not a regular Picture object. What you must do instead is create a new Picture using the Picture property as the source, manipulate the new picture then assign it back to the Picture property to update it. The Picture property will automatically convert a WebPicture into a Picture and back again.

Here is an example:

Var p As Picture = New Picture(ImageViewer1.Width, ImageViewer1.Height)
p.Graphics.DrawPicture(ImageViewer1.Picture, 0 ,0)
p.Graphics.DrawingColor = Color.Red
p.Graphics.FillRectangle(0, 0, 100, 100) // Change the Picture
ImageViewer1.Picture = p // Automatically converts Picture to WebPicture

Optimizing Your Use of Pictures

Pictures that are stored in properties of objects that are sent to the browser (like properties of web pages and controls) are cached locally on the client web browser. If you are always displaying the same picture on a page (or different pages), you can significantly improve performance by caching your picture so that it is not repeatedly sent to the web browser.

For example, if you are creating a custom button control using a subclass of an WebImageViewer control, you could store the two images (normal and pressed states) in two picture properties of the ImageView subclass so that those pictures are only sent to the browser once.

On the app itself (the server side), using a URL does not keep the file in memory. Using a WebFile or WebPicture does keep the file in memory, unless you point it to a file on disk.

AlignVertical and AlignHorizontal Values

Use these class constants with the AlignVertical and AlignHorizontal properties.

Alignment Value
Default (middle) 0
Top 1
Middle 2
Bottom 3

Examples

This example displays a picture (FunnyCat) that has been added to your project:

ImageViewer1.Picture = FunnyCat

See Also

Picture, WebPicture, WebCanvas, WebGraphics