procedure imspalette: palette for image procedure imswidth: width of image procedure imsheight: height of image procedure imsmap: map data of image string procedure imswrite: write image string procedure drawpalette: draw palette procedure pickpalette: key from drawn palette procedure XPMImage: image string for XPM file
link imscolor
December 25, 1999; Gregg M. Townsend
Requires: Version 9 graphics
This file is in the public domain.
These procedures manipulate image strings. imswidth(im) returns the width of an image. imsheight(im) returns the height of an image. imspalette(im) returns the palette used by an image. imsmap(s1, s2, s3) applies map() to the image data. imswrite(f, s, n) writes an image string to a file. drawpalette(W, p, x, y, w, h, f, n) draws the color palette p. pickpalette(W, p, dx, dy, w, h, n) maps window coordinates to a palette drawn by drawpalette(). XPMImage(W, f, p) reads an XPM file, returning an image string. ____________________________________________________________ imswidth(im) returns the width of an image. imsheight(im) returns the height of an image. imspalette(im) returns the palette used by an image. imsmap(s1, s2, s3) returns an image produced by mapping the data (only) of image s1 and replacing characters found in s2 with corresponding characters from s3. imswrite(f, s, n) writes image string s to file f, limiting the line length to n characters. Defaults are f = &output, n = 79. Extra punctuation in s makes the lines break at nonsensical places, but the output is still legal. drawpalette([win,] p, x, y, w, h, f, n) draws the colors of palette p in the given rectangular region. n columns are used; if n is omitted, a layout is chosen based on the palette name and size. The layout algorithm works best when the height is two to four times the width. Characters in the flag string f have these meanings: l label each color with its key o outline each color in black u unframed use: don't hash unused cells at end pickpalette([win,] p, dx, dy, w, h, n) returns the character at (dx,dy) within a region drawn by drawpalette(win, p, x, y, w, h, f, n). XPMImage([win,] f, palette) reads an XPM (X Pixmap) format image from the open file f and returns an Icon image specification that uses the specified palette. XPMImage() fails if it cannot decode the file. If f is omitted, &input is used; if palette is omitted, "c1" is used. Not all variants of XPM format are handled; in particular, images that use more than one significant input character per pixel, or that use the old XPM Version 1 format, cause XPMImage() to fail. No window is required, but X-specific color names like "papayawhip" will not be recognized without a window.