Chapter 12: Portable raster images (cell arrays)

Previous chapter          LLUs Home          Next chapter          Index
Most modern graphics display devices use raster image technology. This means that the physical display surface is made up of a two-dimensional array of pixels, each of which can receive a color value. A displayed picture is nothing more than the aggregate setting and display of all physical pixel color values.

The GKS graphics standard (see the User's Guide for NCAR GKS-0A Graphics for details on GKS) abstracts the concept of a raster image in its cell array function. This function can be invoked, alongside any other NCAR Graphics function, to draw a two-dimensional array of colored rectangles. This array may be of arbitrary size.

Cell array

Representation of the Mandelbrot set where the colors indicate rate of convergence

Table of cell array user entry points

There is only a single entry point discussed in this chapter.

GCA
Takes two corner points defining a rectangle and a number of divisions in the X and Y directions that divide the rectangle into subrectangles, or cells. A color index is specified for each cell, and the resultant cells are drawn in the colors specified.

Creating cell arrays

This module describes how to make calls to the GKS cell array function. This function can be called alongside any other NCAR Graphics function. We will present an example that makes a simple cell array call and uses Plotchar to label the cells.

Simple cell array

Code segment from fcell0.f

1       CALL GSCR(1,0,1.,1.,1.)
2       CALL GSCR(1,1,1.,1.,1.)
3       CALL GSCR(1,2,1.,0.,0.)
4       CALL GSCR(1,3,0.,1.,0.)
5       CALL GSCR(1,4,0.,0.,1.)
6       CALL GSCR(1,5,0.,1.,1.)
7       CALL GSCR(1,6,1.,0.,1.)
8       CALL GSCR(1,7,1.,1.,0.)
9       DO 10 I=1,IDX
10           DO 20 J=1,IDY
11              COLIA(I,J) = IDY*(I-1)+J+1
12  20       CONTINUE
13  10  CONTINUE
14      CALL GCA(0.10, 0.25, 0.90, 0.75, IDX, IDY, 1, 1, IDX, IDY, COLIA)

Synopsis

      CALL GCA (PX, PY, QX, QY, DIMX, DIMY, ISC, ISR, DX, DY, COLIA)

Arguments

PX
Real, Input---A world coordinate specifying an X value for a first corner point of a rectangle.

PY
Real, Input---A world coordinate specifying a Y value for a first corner point of a rectangle.

QX
Real, Input---A world coordinate specifying an X value for a second corner point of a rectangle.

QY
Real, Input---A world coordinate specifying a Y value for a second corner point of a rectangle.

DIMX
Integer, Input---The first dimension of the color index array COLIA (described below).

DIMY
Integer, Input---The second dimension of the color index array COLIA.

ISC
Integer, Input---The index of the starting column to be used from COLIA.

ISR
Integer, Input---The index of the starting row to be used from COLIA.

DX
Integer, Input---The number of columns to use from COLIA (this will equal the number of divisions along the X axis).

DY
Integer, Input---The number of rows to use from COLIA (this will equal the number of divisions along the Y axis).

COLIA
Integer array, Input---An array of color indices dimensioned DIMX by DIMY that is used to assign colors to the individual cells.

Discussion

The points (PX, PY) and (QX, QY) define diagonally opposite corner points of a rectangle. This rectangle is divided into DX by DY cells. The two-dimensional array COLIA specifies a color index for each cell. These color indices are used to color the individual cells.

Lines 1 through 8 of the fcell0.f code segment set up a color table that associates color values with color indices. See the "Color tables and color mapping systems" chapter in this document for details on setting up a color table. An unusual feature of this color table is that the foreground color (color index 1) and the background color (color index 0) are both defined to be white. This is because a white background was desired and the foreground color is used to write text on top of colors that are different from the background color.

Lines 9 through 13 define the color index array where IDX=2 and IDY=3. The six color indices from 2 through 7 are used. These indices are associated with the primary and secondary colors in the color table.

Line 14 calls GCA to produce the cell array. The black-and-white reproduction is less than optimal, so we have used Plotchar to label the cells to indicate what colors you would see if you plotted this picture on a color device.

Cell arrays provide for a way of displaying raster image data along with text, lines, markers, and filled areas. Some data are more suitable for display as a raster image. For example, you may have data from scientific equipment that is in the form of an array of color intensities. Or you may have a screen dump from a graphics output device that is in the form of a raster image. These arrays would have to be converted to a form suitable for using GCA, but once that is done you can integrate such data with the rest of NCAR graphics and display them on multiple output devices.

One disadvantage in using GCA is the case where the resolution of the cell array is not well matched with the resolution of the graphics output device. In this case you may see some "jaggies" or "staircasing" that are consequences of the algorithm that converts the cell array to the raster image on the screen. You could make the size of the cell array match the resolution of a desired output device, but that defeats the intended portability of GCA.

Previous chapter          LLUs Home          Next chapter          Index