Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{rgbimg} --- |
Fred Drake | 67d229e | 1999-02-20 04:51:16 +0000 | [diff] [blame] | 2 | Read and write ``SGI RGB'' files} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | |
Fred Drake | 67d229e | 1999-02-20 04:51:16 +0000 | [diff] [blame] | 4 | \declaremodule{builtin}{rgbimg} |
Fred Drake | 97e3201 | 2001-12-04 16:49:00 +0000 | [diff] [blame] | 5 | \modulesynopsis{Read and write image files in ``SGI RGB'' format (the module |
| 6 | is \emph{not} SGI specific though!).} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 8 | |
Fred Drake | 7932a6b | 1998-04-03 07:09:38 +0000 | [diff] [blame] | 9 | The \module{rgbimg} module allows Python programs to access SGI imglib image |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 10 | files (also known as \file{.rgb} files). The module is far from |
| 11 | complete, but is provided anyway since the functionality that there is |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 12 | enough in some cases. Currently, colormap files are not supported. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 13 | |
Fred Drake | 97e3201 | 2001-12-04 16:49:00 +0000 | [diff] [blame] | 14 | \note{This module is only built by default for 32-bit platforms; it is |
| 15 | not expected to work properly on other systems.} |
| 16 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 17 | The module defines the following variables and functions: |
| 18 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 19 | \begin{excdesc}{error} |
| 20 | This exception is raised on all errors, such as unsupported file type, etc. |
| 21 | \end{excdesc} |
| 22 | |
| 23 | \begin{funcdesc}{sizeofimage}{file} |
| 24 | This function returns a tuple \code{(\var{x}, \var{y})} where |
| 25 | \var{x} and \var{y} are the size of the image in pixels. |
| 26 | Only 4 byte RGBA pixels, 3 byte RGB pixels, and 1 byte greyscale pixels |
| 27 | are currently supported. |
| 28 | \end{funcdesc} |
| 29 | |
| 30 | \begin{funcdesc}{longimagedata}{file} |
| 31 | 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] | 32 | 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] | 33 | The bottom left pixel is the first in |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 34 | the string. This format is suitable to pass to \function{gl.lrectwrite()}, |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 35 | for instance. |
| 36 | \end{funcdesc} |
| 37 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 38 | \begin{funcdesc}{longstoimage}{data, x, y, z, file} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 39 | This function writes the RGBA data in \var{data} to image |
| 40 | file \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 |
| 42 | saved image should be 3 byte RGB data, or 4 if the saved images should |
| 43 | be 4 byte RGBA data. The input data always contains 4 bytes per pixel. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 44 | These are the formats returned by \function{gl.lrectread()}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 45 | \end{funcdesc} |
| 46 | |
| 47 | \begin{funcdesc}{ttob}{flag} |
| 48 | This function sets a global flag which defines whether the scan lines |
| 49 | of the image are read or written from bottom to top (flag is zero, |
| 50 | compatible with SGI GL) or from top to bottom(flag is one, |
Fred Drake | 5208823 | 1998-11-30 16:27:37 +0000 | [diff] [blame] | 51 | compatible with X). The default is zero. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 52 | \end{funcdesc} |