blob: d06eb76e231476914aa23133f18a7cb92745cd3b [file] [log] [blame]
Fred Drake7932a6b1998-04-03 07:09:38 +00001\section{Built-in Module \module{rgbimg}}
Fred Drakeb91e9341998-07-23 17:59:49 +00002\declaremodule{builtin}{rgbimg}
3
4\modulesynopsis{Read and write image files in ``SGI RGB'' format (the module is
5\emph{not} SGI specific though)!}
6
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00007
Fred Drake7932a6b1998-04-03 07:09:38 +00008The \module{rgbimg} module allows Python programs to access SGI imglib image
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00009files (also known as \file{.rgb} files). The module is far from
10complete, but is provided anyway since the functionality that there is
Fred Drakefc576191998-04-04 07:15:02 +000011enough in some cases. Currently, colormap files are not supported.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000012
13The module defines the following variables and functions:
14
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000015\begin{excdesc}{error}
16This exception is raised on all errors, such as unsupported file type, etc.
17\end{excdesc}
18
19\begin{funcdesc}{sizeofimage}{file}
20This function returns a tuple \code{(\var{x}, \var{y})} where
21\var{x} and \var{y} are the size of the image in pixels.
22Only 4 byte RGBA pixels, 3 byte RGB pixels, and 1 byte greyscale pixels
23are currently supported.
24\end{funcdesc}
25
26\begin{funcdesc}{longimagedata}{file}
27This function reads and decodes the image on the specified file, and
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000028returns it as a Python string. The string has 4 byte RGBA pixels.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000029The bottom left pixel is the first in
Fred Drakefc576191998-04-04 07:15:02 +000030the string. This format is suitable to pass to \function{gl.lrectwrite()},
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000031for instance.
32\end{funcdesc}
33
Fred Drakecce10901998-03-17 06:33:25 +000034\begin{funcdesc}{longstoimage}{data, x, y, z, file}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000035This function writes the RGBA data in \var{data} to image
36file \var{file}. \var{x} and \var{y} give the size of the image.
37\var{z} is 1 if the saved image should be 1 byte greyscale, 3 if the
38saved image should be 3 byte RGB data, or 4 if the saved images should
39be 4 byte RGBA data. The input data always contains 4 bytes per pixel.
Fred Drakefc576191998-04-04 07:15:02 +000040These are the formats returned by \function{gl.lrectread()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000041\end{funcdesc}
42
43\begin{funcdesc}{ttob}{flag}
44This function sets a global flag which defines whether the scan lines
45of the image are read or written from bottom to top (flag is zero,
46compatible with SGI GL) or from top to bottom(flag is one,
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000047compatible with X)\@. The default is zero.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000048\end{funcdesc}