Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{imgfile} --- |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 2 | Support for SGI imglib files} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 4 | \declaremodule{builtin}{imgfile} |
| 5 | \platform{IRIX} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 6 | \modulesynopsis{Support for SGI imglib files.} |
| 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{imgfile} 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 |
| 12 | is enough in some cases. Currently, colormap files are not supported. |
| 13 | |
| 14 | The module defines the following variables and functions: |
| 15 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 16 | \begin{excdesc}{error} |
| 17 | This exception is raised on all errors, such as unsupported file type, etc. |
| 18 | \end{excdesc} |
| 19 | |
| 20 | \begin{funcdesc}{getsizes}{file} |
| 21 | This function returns a tuple \code{(\var{x}, \var{y}, \var{z})} where |
| 22 | \var{x} and \var{y} are the size of the image in pixels and |
| 23 | \var{z} is the number of |
| 24 | bytes per pixel. Only 3 byte RGB pixels and 1 byte greyscale pixels |
| 25 | are currently supported. |
| 26 | \end{funcdesc} |
| 27 | |
| 28 | \begin{funcdesc}{read}{file} |
| 29 | This function reads and decodes the image on the specified file, and |
Fred Drake | 7932a6b | 1998-04-03 07:09:38 +0000 | [diff] [blame] | 30 | returns it as a Python string. The string has either 1 byte greyscale |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 31 | pixels or 4 byte RGBA pixels. The bottom left pixel is the first in |
Fred Drake | 7932a6b | 1998-04-03 07:09:38 +0000 | [diff] [blame] | 32 | 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] | 33 | for instance. |
| 34 | \end{funcdesc} |
| 35 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 36 | \begin{funcdesc}{readscaled}{file, x, y, filter\optional{, blur}} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 37 | This function is identical to read but it returns an image that is |
| 38 | scaled to the given \var{x} and \var{y} sizes. If the \var{filter} and |
| 39 | \var{blur} parameters are omitted scaling is done by |
| 40 | simply dropping or duplicating pixels, so the result will be less than |
| 41 | perfect, especially for computer-generated images. |
| 42 | |
| 43 | Alternatively, you can specify a filter to use to smoothen the image |
| 44 | after scaling. The filter forms supported are \code{'impulse'}, |
| 45 | \code{'box'}, \code{'triangle'}, \code{'quadratic'} and |
| 46 | \code{'gaussian'}. If a filter is specified \var{blur} is an optional |
| 47 | parameter specifying the blurriness of the filter. It defaults to \code{1.0}. |
| 48 | |
Fred Drake | a38a286 | 1998-04-11 16:57:05 +0000 | [diff] [blame] | 49 | \function{readscaled()} makes no attempt to keep the aspect ratio |
| 50 | correct, so that is the users' responsibility. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 51 | \end{funcdesc} |
| 52 | |
| 53 | \begin{funcdesc}{ttob}{flag} |
| 54 | This function sets a global flag which defines whether the scan lines |
| 55 | of the image are read or written from bottom to top (flag is zero, |
| 56 | compatible with SGI GL) or from top to bottom(flag is one, |
| 57 | compatible with X). The default is zero. |
| 58 | \end{funcdesc} |
| 59 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 60 | \begin{funcdesc}{write}{file, data, x, y, z} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 61 | This function writes the RGB or greyscale data in \var{data} to image |
| 62 | file \var{file}. \var{x} and \var{y} give the size of the image, |
| 63 | \var{z} is 1 for 1 byte greyscale images or 3 for RGB images (which are |
| 64 | stored as 4 byte values of which only the lower three bytes are used). |
Fred Drake | a38a286 | 1998-04-11 16:57:05 +0000 | [diff] [blame] | 65 | These are the formats returned by \function{gl.lrectread()}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 66 | \end{funcdesc} |