/Doc/library/imgfile.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 73 lines · 45 code · 28 blank · 0 comment · 0 complexity · d7fafb386fdb82d55f3ccf0a2fe786f2 MD5 · raw file

  1. :mod:`imgfile` --- Support for SGI imglib files
  2. ===============================================
  3. .. module:: imgfile
  4. :platform: IRIX
  5. :synopsis: Support for SGI imglib files.
  6. :deprecated:
  7. .. deprecated:: 2.6
  8. The :mod:`imgfile` module has been deprecated for removal in Python 3.0.
  9. The :mod:`imgfile` module allows Python programs to access SGI imglib image
  10. files (also known as :file:`.rgb` files). The module is far from complete, but
  11. is provided anyway since the functionality that there is enough in some cases.
  12. Currently, colormap files are not supported.
  13. The module defines the following variables and functions:
  14. .. exception:: error
  15. This exception is raised on all errors, such as unsupported file type, etc.
  16. .. function:: getsizes(file)
  17. This function returns a tuple ``(x, y, z)`` where *x* and *y* are the size of
  18. the image in pixels and *z* is the number of bytes per pixel. Only 3 byte RGB
  19. pixels and 1 byte greyscale pixels are currently supported.
  20. .. function:: read(file)
  21. This function reads and decodes the image on the specified file, and returns it
  22. as a Python string. The string has either 1 byte greyscale pixels or 4 byte RGBA
  23. pixels. The bottom left pixel is the first in the string. This format is
  24. suitable to pass to :func:`gl.lrectwrite`, for instance.
  25. .. function:: readscaled(file, x, y, filter[, blur])
  26. This function is identical to read but it returns an image that is scaled to the
  27. given *x* and *y* sizes. If the *filter* and *blur* parameters are omitted
  28. scaling is done by simply dropping or duplicating pixels, so the result will be
  29. less than perfect, especially for computer-generated images.
  30. Alternatively, you can specify a filter to use to smooth the image after
  31. scaling. The filter forms supported are ``'impulse'``, ``'box'``,
  32. ``'triangle'``, ``'quadratic'`` and ``'gaussian'``. If a filter is specified
  33. *blur* is an optional parameter specifying the blurriness of the filter. It
  34. defaults to ``1.0``.
  35. :func:`readscaled` makes no attempt to keep the aspect ratio correct, so that is
  36. the users' responsibility.
  37. .. function:: ttob(flag)
  38. This function sets a global flag which defines whether the scan lines of the
  39. image are read or written from bottom to top (flag is zero, compatible with SGI
  40. GL) or from top to bottom(flag is one, compatible with X). The default is zero.
  41. .. function:: write(file, data, x, y, z)
  42. This function writes the RGB or greyscale data in *data* to image file *file*.
  43. *x* and *y* give the size of the image, *z* is 1 for 1 byte greyscale images or
  44. 3 for RGB images (which are stored as 4 byte values of which only the lower
  45. three bytes are used). These are the formats returned by :func:`gl.lrectread`.