<< Prev | - Up - | Next >> |
Besides of text and bitmaps labels can display images. Images differ from bitmaps in that they allow for more than two colors to be displayed.
Images are provided as objects in Oz. These objects are also tickle objects (see Section 3.2), but are different from widget objects.
D ={Property.get 'oz.home'}#'/doc/wp/'
I ={New Tk.image tkInit(type:photo format:ppm file:D#'truck-left.ppm')}
L1={New Tk.label tkInit(parent:W image:I)}
L2={New Tk.label tkInit(parent:W image:I)}
L3={New Tk.label tkInit(parent:W image:I)}
{Tk.send pack(L1 L2 L3 padx:1#m pady:1#m side:left)}
The program in Figure 3.6 creates an image object and displays the image in three labels. Changing the configuration of the image, changes the displayed image in all label widgets. For example, feeding the following expression
{I tk(configure file:D#'truck-right.ppm')}
replaces all three displayed trucks by trucks heading in the inverse direction.
type and format
Images can be of two different types. The value of the type
configuration option can be photo
(as in our example), or bitmap
. If the type is photo
, the image can display files in two different formats. The format is specified by the format
option. Valid values for the format
option are gif
and ppm
.
bitmap images
In case the value for the type
option is bitmap
, the value given for the file
option must be a valid bitmap file.
referring to images by URLs
In addition to files, images can also be referred to by URLs. For example,
{New Tk.image tkInit(type:photo format:gif
url:'http://foo.com/bar.gif'}
would have loaded a gif file from the given URL. Note that the graphics engine itself is not capable of handling URLs. Instead, the image object handles URLs by localizing a URL to a local file (see also Chapter 15 of ``System Modules''). The local file then is used by the graphics engine.
In Section 8.4 an abstraction is presented that eases the handling of images considerably.
Reference information on images can be found in image.
<< Prev | - Up - | Next >> |