blob: 73e4aaebb236bc22ec5739cc4c1bc87013f6649f [file] [log] [blame]
Fred Drake7932a6b1998-04-03 07:09:38 +00001\section{Built-in Module \module{rgbimg}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-rgbimg}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00003\bimodindex{rgbimg}
4
Fred Drake7932a6b1998-04-03 07:09:38 +00005The \module{rgbimg} module allows Python programs to access SGI imglib image
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00006files (also known as \file{.rgb} files). The module is far from
7complete, but is provided anyway since the functionality that there is
Fred Drakefc576191998-04-04 07:15:02 +00008enough in some cases. Currently, colormap files are not supported.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00009
10The module defines the following variables and functions:
11
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000012\begin{excdesc}{error}
13This exception is raised on all errors, such as unsupported file type, etc.
14\end{excdesc}
15
16\begin{funcdesc}{sizeofimage}{file}
17This function returns a tuple \code{(\var{x}, \var{y})} where
18\var{x} and \var{y} are the size of the image in pixels.
19Only 4 byte RGBA pixels, 3 byte RGB pixels, and 1 byte greyscale pixels
20are currently supported.
21\end{funcdesc}
22
23\begin{funcdesc}{longimagedata}{file}
24This function reads and decodes the image on the specified file, and
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000025returns it as a Python string. The string has 4 byte RGBA pixels.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000026The bottom left pixel is the first in
Fred Drakefc576191998-04-04 07:15:02 +000027the string. This format is suitable to pass to \function{gl.lrectwrite()},
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000028for instance.
29\end{funcdesc}
30
Fred Drakecce10901998-03-17 06:33:25 +000031\begin{funcdesc}{longstoimage}{data, x, y, z, file}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000032This function writes the RGBA data in \var{data} to image
33file \var{file}. \var{x} and \var{y} give the size of the image.
34\var{z} is 1 if the saved image should be 1 byte greyscale, 3 if the
35saved image should be 3 byte RGB data, or 4 if the saved images should
36be 4 byte RGBA data. The input data always contains 4 bytes per pixel.
Fred Drakefc576191998-04-04 07:15:02 +000037These are the formats returned by \function{gl.lrectread()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000038\end{funcdesc}
39
40\begin{funcdesc}{ttob}{flag}
41This function sets a global flag which defines whether the scan lines
42of the image are read or written from bottom to top (flag is zero,
43compatible with SGI GL) or from top to bottom(flag is one,
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000044compatible with X)\@. The default is zero.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000045\end{funcdesc}