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