Next Previous Contents

6. Image Display

6.1 imdisplay

Synopsis

A lightweight image compositing, transform, and display function

Usage

imdisplay( FileName_or_ImageArray_or_Option [, ...])

Description

This function accepts an arbitrary number of images as input, and by default renders them stacked upon one another, respecting transparency. The composite image may be easily tiled or scaled, as well as auto- matically scrolled for images too large to fit reasonably within your display. Alternatively, the panes option may be used to display each image within its own window, tiled either vertically or horizontally.

The images passed in may be names of files, GDK pixbufs, or S-Lang arrays (2D/greyscale, 3D/RGB, or 3D/RGBA). If any input image in a composite contains an alpha channel (transparency) then the rendered result will as well.

A wide variety of file formats are supported, including FITS, JPEG, PNG, GIF, XPM, TIFF, and animations. The rendered result may also be saved to a variety of formats, including JPEG, PNG, and FITS. The range of supported formats depends upon how your Gtk distribution was compiled.

Optional strings specifying basic transformations may be included within the input parameters. Most of these are performed on the composite image just prior to display, and include:

        "flip"                  mirror the image vertically
        "flop"                  mirror the image horizontally
        "size=<geometry>" resize the image; geometry may either
                                be a scaling percentage or an absolute
                                pixel size, such as 150x200% or 100x300;
                                when only one value is provided it will
                                be applied to both axes of the image

        "fill=<rule>"           how to fill new space created in image
                                display window when it is enlarged; one of

                                   none    no fill; keep original image
                                   tile    fill with consecutive image copies
                                   scale   fill by enlarging image to fit

        "panes=<layout>"        how to display multiple images; layout may be

                                one | single    composite all images into
                                                one window (the default)
                                horiz[ontal]    tile images horizontally
                                vert[ical]      tile images vertically

                                No compositing is performed for horizontal
                                or vertical tiling.
The default display options may be changed with imdisplay_defaults(); the new defaults will persist between subsequent invocations of imdisplay() (in the same process) or until imdisplay_defaults() is called with no arguments.

At launch all of the windows created by imdisplay will be chained: e.g. the control window will be chained to the window of the last image loaded, meaning that the controller will follow the image window around onscreen when the latter is moved; when the controller is moved its new gravity (i.e. placement relative to the image) will be remembered. An entire vertical (or horizontal) tiling of windows may be moved simply by moving its top- (or left-) most window.

To disable chaining, ensure that the slave window you wish to unchain has focus, then hold down the SHIFT key while moving the slave. This will disconnect the slave from its own master, but leave intact any chains in which the slave is itself a master.

Example

The sequence of commands

        unix% cd <slgtk_distribution_on_your_system>/images

        unix% slsh
        slsh> require("imdisplay")

        slsh> pb1 = gdk_pixbuf_new_from_file("stars.fits")
        slsh> im1 = _reshape( [1:200*300], [200,300])
        slsh>  imdisplay(im1, pb1, "gtk-logo-rgb.gif", "flip,size=70%", "red.png")
should yield the visual


 Similarly,

        slsh> red = UChar_Type[100,100,4]
        slsh> red[*,*,0] = 255
        slsh> red[*,*,3] = 127                       % 50% transparency
        slsh> blue = UChar_Type[200,200,3]
        slsh> blue[*,*,2] = 255
        slsh> imdisplay("size=211x79", blue, "flip", red, "flop")

  should yield

Notes

imdisplay may also be used from the OS prompt as an executable script. In this form only files may be loaded, but all other options are supported, including the "help" switch which provides detailed usage information.


Next Previous Contents