HDK
|
Images are loaded and saved by the IMG_File class, which provides a variety of features:
The easiest way to load an image file is to open()
it, readImages()
from it, and then close()
the file.
The following sections describe this process in more detail.
To open an image for reading, pass the filename to IMG_File::open(). You can also pass in an IMG_FileParms structure to tell the loader how to organize your data. By using the IMG_FileParms correctly, you may be able to avoid the need to post-process the scanline data. Not all the parameters are available for writing, since most of the data for the write is specified in the IMG_Stat. See the "Write Effect" section in each for what applies to writing and what is ignored.
IMG_FileParms allows you to do the following:
Raster depth conversion and RGB/RGBA conversions are common re-organizations. Now, you can also specify if you want the data interleaved (RGBRGBRGB) or non-interleaved (RRRGGGBBB) or as-is.
By default, the data is interleaved and left at the native raster depth and color model.
These are the effects of the above IMG_FileParms methods when writing:
- setDataType() - write the data as type (if supported by format). - setColorModel() - write the data in model model (if supported by format). - setInterleaved() - specifies how we are passing the data - as interleaved or non-interleaved (default interleaved). - setLuminanceFunc() - if demoting an RGB(A) plane to a single channel, specifies how to do it. - all others - ignored for writing.
In addition to scaling to a given resolution, the new API also supports some more common scale operations. Most of these are mutually exclusive. To do cropping instead of scaling, see Data Window below.
By default, the native resolution is used.
ignored for all.
Data windows can be embedded in certain file formats, but you can also specify your own window (regardless of whether a data window exists in the file). When specifying a subregion to read, you will be reading that area, not the full image area.
By default, all file data windows are expanded to fill the entire image.
ignored for all.
In addition to being able to flip a file vertically, the new API allows you to specify an orientation and then flip horizontally or vertically. You can also flop the image (rotate it 90'). The orientation and flip work together to avoid doubling flipping.
By default, the image is read so that the (0,0) pixel is in the bottom left corner of the image.
Specifies how to flip the image when outputting. flopImage() ignored.
You can also specify color correction to be applied to the image before any of its data is converted (ie, if you're converting a FP image to an 8 bit texture, you can apply gamma and/or a LUT first, before quantization occurs).
By default, no color correction is performed.
Applies a LUT and gamma to the output planes which match the scope.
You can set format-specific options, like compression, through the IMG_FileParms::setOption() method. This is still relatively simplistic, as it takes a string for both option name and value. This may be upgraded later.
You can use a tile-based interface to IMG_File for writing data as well. Internally, this still uses scanlines. This is a convenience function for ease of data manipulation only.
It's possible to extend SOHO to add image options the user can pass to the image format being rendered. If you examine $HH/soho/python