blob: 86978d8cbf8442f1eac7bf344c43141a084e0dfb [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{rgbimg} ---
Fred Drake67d229e1999-02-20 04:51:16 +00002 Read and write ``SGI RGB'' files}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drake67d229e1999-02-20 04:51:16 +00004\declaremodule{builtin}{rgbimg}
Fred Drake97e32012001-12-04 16:49:00 +00005\modulesynopsis{Read and write image files in ``SGI RGB'' format (the module
6 is \emph{not} SGI specific though!).}
Fred Drakeb91e9341998-07-23 17:59:49 +00007
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00008
Fred Drake7932a6b1998-04-03 07:09:38 +00009The \module{rgbimg} module allows Python programs to access SGI imglib image
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000010files (also known as \file{.rgb} files). The module is far from
11complete, but is provided anyway since the functionality that there is
Fred Drakefc576191998-04-04 07:15:02 +000012enough in some cases. Currently, colormap files are not supported.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000013
Fred Drake97e32012001-12-04 16:49:00 +000014\note{This module is only built by default for 32-bit platforms; it is
15not expected to work properly on other systems.}
16
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000017The module defines the following variables and functions:
18
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000019\begin{excdesc}{error}
20This exception is raised on all errors, such as unsupported file type, etc.
21\end{excdesc}
22
23\begin{funcdesc}{sizeofimage}{file}
24This function returns a tuple \code{(\var{x}, \var{y})} where
25\var{x} and \var{y} are the size of the image in pixels.
26Only 4 byte RGBA pixels, 3 byte RGB pixels, and 1 byte greyscale pixels
27are currently supported.
28\end{funcdesc}
29
30\begin{funcdesc}{longimagedata}{file}
31This function reads and decodes the image on the specified file, and
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000032returns it as a Python string. The string has 4 byte RGBA pixels.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000033The bottom left pixel is the first in
Fred Drakefc576191998-04-04 07:15:02 +000034the string. This format is suitable to pass to \function{gl.lrectwrite()},
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000035for instance.
36\end{funcdesc}
37
Fred Drakecce10901998-03-17 06:33:25 +000038\begin{funcdesc}{longstoimage}{data, x, y, z, file}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000039This function writes the RGBA data in \var{data} to image
40file \var{file}. \var{x} and \var{y} give the size of the image.
41\var{z} is 1 if the saved image should be 1 byte greyscale, 3 if the
42saved image should be 3 byte RGB data, or 4 if the saved images should
43be 4 byte RGBA data. The input data always contains 4 bytes per pixel.
Fred Drakefc576191998-04-04 07:15:02 +000044These are the formats returned by \function{gl.lrectread()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000045\end{funcdesc}
46
47\begin{funcdesc}{ttob}{flag}
48This function sets a global flag which defines whether the scan lines
49of the image are read or written from bottom to top (flag is zero,
50compatible with SGI GL) or from top to bottom(flag is one,
Fred Drake52088231998-11-30 16:27:37 +000051compatible with X). The default is zero.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000052\end{funcdesc}