WebPicture.Constructor(Source as Picture, Format as String = "public.png")

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


WebPicture.Constructor(Source as Picture[, Format as String= "public.png"])

New in 2010r5

Creates a WebPicture from the passed Source Picture in the format specified by Format. Format is one of the 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.


The following table gives the values of the available picture format constants and their values.

Class Constant Value
FormatBMP com.microsoft.bmp
FormatGIF com.compuserve.gif
FormatJPEG public.jpeg
FormatPNG public.png
FormatTIFF public.tiff


Convert a Picture, created at runtime to a WebPicture to display using a WebImageView:

Var p As New Picture(100, 100, 32)
p.Graphics.ForeColor = &c0000ff // Blue
p.Graphics.FillRect(10, 10, 50, 50)

Var wp As New WebPicture(p)
ImageView1.Picture = wp

To instead create the picture as a JPEG, use this code:

Var wp As New WebPicture(p, WebPicture.FormatJPEG)