1 | \section{\module{imgfile} ---
|
---|
2 | Support for SGI imglib files}
|
---|
3 |
|
---|
4 | \declaremodule{builtin}{imgfile}
|
---|
5 | \platform{IRIX}
|
---|
6 | \modulesynopsis{Support for SGI imglib files.}
|
---|
7 |
|
---|
8 |
|
---|
9 | The \module{imgfile} module allows Python programs to access SGI imglib image
|
---|
10 | files (also known as \file{.rgb} files). The module is far from
|
---|
11 | complete, but is provided anyway since the functionality that there is
|
---|
12 | enough in some cases. Currently, colormap files are not supported.
|
---|
13 |
|
---|
14 | The module defines the following variables and functions:
|
---|
15 |
|
---|
16 | \begin{excdesc}{error}
|
---|
17 | This exception is raised on all errors, such as unsupported file type, etc.
|
---|
18 | \end{excdesc}
|
---|
19 |
|
---|
20 | \begin{funcdesc}{getsizes}{file}
|
---|
21 | This function returns a tuple \code{(\var{x}, \var{y}, \var{z})} where
|
---|
22 | \var{x} and \var{y} are the size of the image in pixels and
|
---|
23 | \var{z} is the number of
|
---|
24 | bytes per pixel. Only 3 byte RGB pixels and 1 byte greyscale pixels
|
---|
25 | are currently supported.
|
---|
26 | \end{funcdesc}
|
---|
27 |
|
---|
28 | \begin{funcdesc}{read}{file}
|
---|
29 | This function reads and decodes the image on the specified file, and
|
---|
30 | returns it as a Python string. The string has either 1 byte greyscale
|
---|
31 | pixels or 4 byte RGBA pixels. The bottom left pixel is the first in
|
---|
32 | the string. This format is suitable to pass to \function{gl.lrectwrite()},
|
---|
33 | for instance.
|
---|
34 | \end{funcdesc}
|
---|
35 |
|
---|
36 | \begin{funcdesc}{readscaled}{file, x, y, filter\optional{, blur}}
|
---|
37 | This function is identical to read but it returns an image that is
|
---|
38 | scaled to the given \var{x} and \var{y} sizes. If the \var{filter} and
|
---|
39 | \var{blur} parameters are omitted scaling is done by
|
---|
40 | simply dropping or duplicating pixels, so the result will be less than
|
---|
41 | perfect, especially for computer-generated images.
|
---|
42 |
|
---|
43 | Alternatively, you can specify a filter to use to smooth the image
|
---|
44 | after scaling. The filter forms supported are \code{'impulse'},
|
---|
45 | \code{'box'}, \code{'triangle'}, \code{'quadratic'} and
|
---|
46 | \code{'gaussian'}. If a filter is specified \var{blur} is an optional
|
---|
47 | parameter specifying the blurriness of the filter. It defaults to \code{1.0}.
|
---|
48 |
|
---|
49 | \function{readscaled()} makes no attempt to keep the aspect ratio
|
---|
50 | correct, so that is the users' responsibility.
|
---|
51 | \end{funcdesc}
|
---|
52 |
|
---|
53 | \begin{funcdesc}{ttob}{flag}
|
---|
54 | This function sets a global flag which defines whether the scan lines
|
---|
55 | of the image are read or written from bottom to top (flag is zero,
|
---|
56 | compatible with SGI GL) or from top to bottom(flag is one,
|
---|
57 | compatible with X). The default is zero.
|
---|
58 | \end{funcdesc}
|
---|
59 |
|
---|
60 | \begin{funcdesc}{write}{file, data, x, y, z}
|
---|
61 | This function writes the RGB or greyscale data in \var{data} to image
|
---|
62 | file \var{file}. \var{x} and \var{y} give the size of the image,
|
---|
63 | \var{z} is 1 for 1 byte greyscale images or 3 for RGB images (which are
|
---|
64 | stored as 4 byte values of which only the lower three bytes are used).
|
---|
65 | These are the formats returned by \function{gl.lrectread()}.
|
---|
66 | \end{funcdesc}
|
---|