
|
|
ImageReader
What Is It?
ImageReader is a trueSpace Python extension for reading images.
It provides information about the image size, along with the RGB
(and alpha channel, if present) data.
Usage
Currently the API is made up of two functions
img = ImageReader.read(filename)
The returned content is a tuple containing two items
[[width, height, alphaflag], [[r, g, b], ..., [r, g, b]]]
or, if the image contains an alpha channel
[[width, height, alphaflag], [[r, g, b, a], ..., [r, g, b, a]]]
The r, g, b and a values are byte values between 0 and 255.
The other call
imgInfo = ImageReader.info(filename)
simply returns
[width, height, alphaflag]
Installation
Installation is a matter of copying ImageReader.dll to either
the main trueSpace directory, or preferably, a Lib directory inside
the main trueSpace directory. ImageReader is compatible with trueSpace
5.0 and higher. It has not been tested with trueSpace 4.3.
Supported Image
Types
The image types recognized are BMP, JPG, PNG, TIF, TGA, GIF and
PCX.
Example
import trueSpace
import ImageReader
filename = "..."
img = ImageReader.read(filename)
print "Width : ", img[0][0], "\n"
print "Height: ", img[0][1], "\n"
print "Alpha : ", img[0][2], "\n"
print "First
RGB: "
print img[1][0][0], ","
print img[1][0][1], ","
print img[1][0][2], "\n"
print "Second
RGB: "
print img[1][1][0], ","
print img[1][1][1], ","
print img[1][1][2], "\n"
img = ImageReader.info(filename)
print "Width : ", img[0], "\n"
print "Height: ", img[1], "\n"
print "Alpha : ", img[2], "\n"
trueSpace.Stop()
Credits
This project would not have been completed without the CxImage
library, an easy to use bitmap image loading and saving library.
It is copyright David Pizzolato, and can be found at http://www.codeproject.com/bitmap/cximage.asp.
This software is based in part on the work of the Independent JPEG
Group.
Download ImageReader.zip
|