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