Classes of main interest are:
Smalltalk/X supports black & white, greyscale and color images with resolutions of 1, 2, 4, 8, 16 or 24 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:
Some image manipulation functionality is provided by the Image classes; for example, flip, rotate, shrink and magnify (by arbitrary factors).
Typical uses:
anImage := Image fromFile:fileName
magnifiedImage := anImage magnifiedBy:scalePoint
aView viewBackground:anImage
aTopView icon:anImage
aView displayImage:anImage
Example:
as icon:
(Image fromFile:'bitmaps/gifImages/garfield.gif') inspect
as view background:
|myView|
myView := StandardSystemView new.
myView extent:200@200.
myView icon:(Image fromFile:'bitmaps/hello_world.icon').
myView open
as drawing pens color:
|myView|
myView := View new.
myView viewBackground:((Image fromFile:'bitmaps/SmalltalkX.xbm') magnifiedBy:1.5).
myView open
another drawing pens color:
|myView|
myView := View new.
myView extent:200@200.
myView openAndWait.
myView paint:((Image fromFile:'bitmaps/SmalltalkX.xbm') magnifiedBy:0.3).
myView lineWidth:10.
myView displayLineFrom:10@10 to:100@100.
myView displayLineFrom:100@10 to:10@100.
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.
|myView|
myView := View new.
myView extent:200@200.
myView openAndWait.
myView paint:(Image fromFile:'bitmaps/woodH.tiff') on:(Color yellow).
myView font:(Font family:'helvetica' face:'bold' size:36).
myView displayOpaqueString:'hello' at:50@50.
Therefore, images are usually kept in some instance or class variable
and reused (cached). The above examples are somewhat unrealistic.
Copyright © 1995 Claus Gittinger Development & Consulting
<cg@exept.de>