| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (9 out of 18)

Including Externally Created Images

An image is a GIF or XBM file that has been made available within G2 via an image definition, as described in Chapter 30, External Images. Images typically contain screen captures, scanned-in photographs, or other complex graphics.

You can use the Icon Editor to define a single image as a component of a layer, and to combine such layers into one layer with multiple images. A layer that includes an image can also contain other graphics and text defined with the Icon Editor, just as if no image were present.

An image used in an icon appears in monochrome, even though the original bitmap may be polychrome. An image behaves like any other graphic with respect to occlusion, color, grouping, and region definition. The same image can be included in more than one layer. In each layer, it takes on that layer's color.

The Layer Indicators include an Image Indicator for including an image in a layer. When a layer has multiple images, only the first shows in the Image Indicator. All image components appear in the icon description in the class definition's table.

Various GIFs that can be used as external images in icons are available in the G2 demos directory, as described under GIF Files.

To include an image in an icon:

  1. Select the layer that is to contain the image.

  2. Click on the value of the Image Indicator to invoke the Text Editor.

    The editor lists all currently defined images.

  3. Edit the Image Indicator to contain the name of the image.

The image appears in the layer as soon as you close the Text Editor.

To put more than one image into a layer, specify each in a separate layer, then combine the layers using the Group button, as described under Creating Groups. Only the first image in the combined layer appears in the layer's Image Indicator. Use Ungroup to regain separate access to the components of the combined layer.

Image Size and Icon Size

The size of an image does not affect the icon size. When the icon's width and/or height is larger than the image, the image occupies only a portion of the icon. When the icon's width and/or height is smaller than the image, the image is cropped at the boundary of the icon.

To have an image determine the icon size:

Image definition tables are described under Creating an Image Definition.

Image Position

By default, G2 positions an image with its top left corner (the image's (0, 0)) at the top left corner of its layer (the layer's (0,0)). To position an image elsewhere in its layer, you can enter an (X, Y) offset after the image name.

The numbers in the offset represent workspace units, and can be negative. The editor offsets the image horizontally by the amount of the X offset, and vertically by the amount of the Y offset. A negative X offsets the image to the left, and a negative Y offsets the image upwards. Such an offset crops the image on the left and/or top.

To position an image in a layer:

  1. Click in the Image value to edit the image name.

    After the name of the image, the editor prompts you with at.

  2. Enter an (X, Y) offset, for example:

The image wizard now appears in its layer with its upper left corner 18 units to the right and 20 units down from the upper left corner of the icon. If the size of the icon is 100x100, and the size of the image is 64x54, this offset positions the image just above the center of the icon:


| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (9 out of 18)

Copyright © 1997 Gensym Corporation, Inc.