[prev] [up] [next]

Classes of main interest are:

Image - bitmap images

Smalltalk/X supports black & white, greyscale and color images with resolutions of 1, 2, 4, 8, 16, 24 and 32 bits per pixel. Independent of its depth, any image may have a photometric of greyScale, palette (i.e. uses a color lookup table) or trueColor.

When displayed, images are approximated (i.e. dithered) if the displays capabilities force this. For example, conversion of color images to dithered black & white or greyscale images is done automatically.

Images can be imported (i.e. loaded from a file) in a number of formats; among others, the common formats are supported:

Export of images (i.e. saving to a file) is supported in PNG, BMP, GIF, TIFF, XBM and XPM formats; other formats may be added upon request (or provided by third parties).

Some image manipulation functionality is provided by the Image classes; for example, flip, rotate, shrink and magnify (by arbitrary factors).

Typical uses:

Example:

    (Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') inspect
as icon:
    |myView|

    myView := StandardSystemView new.
    myView extent:200@200.
    myView icon:(Image fromFile:'../../goodies/bitmaps/xbmBitmaps/TicTacToe.xbm').
    myView open
as view background:
    |myView|

    myView := View new.
    myView viewBackground:((Image fromFile:'../../goodies/bitmaps/xbmBitmaps/TicTacToe.xbm') magnifiedBy:1.5).
    myView open
as drawing pens color:
    |myView|

    myView := View new.
    myView extent:200@200.
    myView openAndWait.

    myView paint:((Image fromFile:'../../goodies/bitmaps/xbmBitmaps/TicTacToe.xbm') magnifiedBy:0.3).
    myView lineWidth:10.
    myView displayLineFrom:10@10 to:100@100.
    myView displayLineFrom:100@10 to:10@100.
another drawing pens color:
    |myView|

    myView := View new.
    myView extent:400@200.
    myView openAndWait.

    myView paint:(Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/argentina.xpm') on:(Color yellow).
    myView font:(Font family:'helvetica' face:'bold' size:64).
    myView displayOpaqueString:'hello' at:50@50.
Notice, that it may take some time to load images from a file, and also to allocate colors and convert the image for the display device.
Therefore, images are usually kept in some instance or class variable and reused (cached). The above examples are somewhat unrealistic.

Press here for more details about: Image.

ImageReader - Bitmap Image I/O

ImageReader is itself an abstract class; concrete subclasses care for the various supported image formats. Although the names of these classes imply readers, most of them also support writing of bitmap images. For example, PNG, GIF, TIFF and BMP files can also be written.
As an example, the following code reads an image in GIF-format, and writes it into another file in the BMP format:

    |img|

    img := Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'.
    img saveAs:'garfield.bmp'.
if programmed as above, the format is choosen by the saveAs: method acording to the files extension. This may not always be the correct choice. An explicit reader should be used, if in doubt:
    |img|

    img := Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'.
    WindowsIconReader save:img onFile:'garfield.foo'.

Press here for more details about: ImageReader.


Copyright 1995 Claus Gittinger Development & Consulting

<cg@exept.de>

Doc $Revision: 1.22 $ $Date: 2016/01/21 16:22:39 $