#include <imageio.h>
Public Types | |
enum | Linearity { UnknownLinearity = 0, Linear = 1, GammaCorrected = 2, sRGB = 3 } |
Public Member Functions | |
ImageSpec (TypeDesc format=TypeDesc::UNKNOWN) | |
ImageSpec (int xres, int yres, int nchans, TypeDesc fmt=TypeDesc::UINT8) | |
void | set_format (TypeDesc fmt) |
void | default_channel_names () |
size_t | channel_bytes () const |
size_t | pixel_bytes () const |
imagesize_t | scanline_bytes () const |
imagesize_t | tile_pixels () const |
imagesize_t | tile_bytes () const |
imagesize_t | image_pixels () const |
imagesize_t | image_bytes () const |
bool | size_t_safe () const |
void | attribute (const std::string &name, TypeDesc type, const void *value) |
void | attribute (const std::string &name, unsigned int value) |
void | attribute (const std::string &name, int value) |
void | attribute (const std::string &name, float value) |
void | attribute (const std::string &name, const char *value) |
void | attribute (const std::string &name, const std::string &value) |
ImageIOParameter * | find_attribute (const std::string &name, TypeDesc searchtype=TypeDesc::UNKNOWN, bool casesensitive=false) |
const ImageIOParameter * | find_attribute (const std::string &name, TypeDesc searchtype=TypeDesc::UNKNOWN, bool casesensitive=false) const |
int | get_int_attribute (const std::string &name, int defaultval=0) const |
float | get_float_attribute (const std::string &name, float defaultval=0) const |
std::string | get_string_attribute (const std::string &name, const std::string &defaultval=std::string()) const |
std::string | metadata_val (const ImageIOParameter &p, bool human=false) const |
Static Public Member Functions | |
static TypeDesc | format_from_quantize (int quant_black, int quant_white, int quant_min, int quant_max) |
static void | auto_stride (stride_t &xstride, stride_t &ystride, stride_t &zstride, TypeDesc format, int nchannels, int width, int height) |
static void | auto_stride (stride_t &xstride, TypeDesc format, int nchannels) |
Public Attributes | |
int | x |
int | y |
int | z |
origin (upper left corner) of pixel data | |
int | width |
width of the pixel data window | |
int | height |
height of the pixel data window | |
int | depth |
depth of pixel data, >1 indicates a "volume" | |
int | full_x |
origin of the full (display) window | |
int | full_y |
origin of the full (display) window | |
int | full_z |
origin of the full (display) window | |
int | full_width |
width of the full (display) window | |
int | full_height |
height of the full (display) window | |
int | full_depth |
depth of the full (display) window | |
int | tile_width |
tile width (0 for a non-tiled image) | |
int | tile_height |
tile height (0 for a non-tiled image) | |
int | tile_depth |
TypeDesc | format |
int | nchannels |
number of image channels, e.g., 4 for RGBA | |
std::vector< std::string > | channelnames |
int | alpha_channel |
Index of alpha channel, or -1 if not known. | |
int | z_channel |
Index of depth channel, or -1 if not known. | |
Linearity | linearity |
Value mapping of color channels. | |
float | gamma |
gamma exponent of the values in the file | |
int | quant_black |
quantization of black (0.0) level | |
int | quant_white |
quantization of white (1.0) level | |
int | quant_min |
quantization minimum clamp value | |
int | quant_max |
quantization maximum clamp value | |
float | quant_dither |
dither amplitude for quantization | |
ImageIOParameterList | extra_attribs |
Additional attributes. |
ImageSpec describes the data format of an image -- dimensions, layout, number and meanings of image channels.
OpenImageIO::ImageSpec::ImageSpec | ( | TypeDesc | format = TypeDesc::UNKNOWN |
) |
Constructor: given just the data format, set the default quantize and dither and set all other channels to something reasonable.
OpenImageIO::ImageSpec::ImageSpec | ( | int | xres, | |
int | yres, | |||
int | nchans, | |||
TypeDesc | fmt = TypeDesc::UINT8 | |||
) |
Constructor for simple 2D scanline image with nothing special. If fmt is not supplied, default to unsigned 8-bit data.
void OpenImageIO::ImageSpec::attribute | ( | const std::string & | name, | |
const std::string & | value | |||
) | [inline] |
Add a string attribute
void OpenImageIO::ImageSpec::attribute | ( | const std::string & | name, | |
const char * | value | |||
) | [inline] |
Add a string attribute
void OpenImageIO::ImageSpec::attribute | ( | const std::string & | name, | |
float | value | |||
) | [inline] |
Add a float attribute
void OpenImageIO::ImageSpec::attribute | ( | const std::string & | name, | |
int | value | |||
) | [inline] |
Add an int attribute
void OpenImageIO::ImageSpec::attribute | ( | const std::string & | name, | |
unsigned int | value | |||
) | [inline] |
Add an unsigned int attribute
void OpenImageIO::ImageSpec::attribute | ( | const std::string & | name, | |
TypeDesc | type, | |||
const void * | value | |||
) |
Add an optional attribute to the extra attribute list
static void OpenImageIO::ImageSpec::auto_stride | ( | stride_t & | xstride, | |
TypeDesc | format, | |||
int | nchannels | |||
) | [inline, static] |
Adjust xstride, if set to AutoStride, to be the right size for contiguous data with the given format and channels.
static void OpenImageIO::ImageSpec::auto_stride | ( | stride_t & | xstride, | |
stride_t & | ystride, | |||
stride_t & | zstride, | |||
TypeDesc | format, | |||
int | nchannels, | |||
int | width, | |||
int | height | |||
) | [inline, static] |
Adjust the stride values, if set to AutoStride, to be the right sizes for contiguous data with the given format, channels, width, height.
size_t OpenImageIO::ImageSpec::channel_bytes | ( | ) | const [inline] |
Return the number of bytes for each channel datum
void OpenImageIO::ImageSpec::default_channel_names | ( | ) |
Set the channelnames to reasonable defaults ("R", "G", "B", "A"), and alpha_channel, based on the number of channels.
ImageIOParameter* OpenImageIO::ImageSpec::find_attribute | ( | const std::string & | name, | |
TypeDesc | searchtype = TypeDesc::UNKNOWN , |
|||
bool | casesensitive = false | |||
) |
Search for a attribute of the given name in the list of extra attributes.
static TypeDesc OpenImageIO::ImageSpec::format_from_quantize | ( | int | quant_black, | |
int | quant_white, | |||
int | quant_min, | |||
int | quant_max | |||
) | [static] |
Given quantization parameters, deduce a TypeDesc that can be used without unacceptable loss of significant bits.
float OpenImageIO::ImageSpec::get_float_attribute | ( | const std::string & | name, | |
float | defaultval = 0 | |||
) | const |
Simple way to get a float attribute, with default provided. Automatically will return a float even if the data is really double or half.
int OpenImageIO::ImageSpec::get_int_attribute | ( | const std::string & | name, | |
int | defaultval = 0 | |||
) | const |
Simple way to get an integer attribute, with default provided. Automatically will return an int even if the data is really unsigned, short, or byte.
std::string OpenImageIO::ImageSpec::get_string_attribute | ( | const std::string & | name, | |
const std::string & | defaultval = std::string() | |||
) | const |
Simple way to get a string attribute, with default provided.
imagesize_t OpenImageIO::ImageSpec::image_bytes | ( | ) | const |
Return the number of bytes for an entire image. This will return std::numeric_limits<image size_t>::max() in the event of an overflow where it's not representable in an imagesize_t.
imagesize_t OpenImageIO::ImageSpec::image_pixels | ( | ) | const |
Return the number of pixels for an entire image. This will return std::numeric_limits<imagesize_t>::max() in the event of an overflow where it's not representable in an imagesize_t.
std::string OpenImageIO::ImageSpec::metadata_val | ( | const ImageIOParameter & | p, | |
bool | human = false | |||
) | const |
For a given parameter (in this ImageSpec's extra_attribs), format the value nicely as a string. If 'human' is true, use especially human-readable explanations (units, or decoding of values) for certain known metadata.
size_t OpenImageIO::ImageSpec::pixel_bytes | ( | ) | const |
Return the number of bytes for each pixel (counting all channels). This will return std::numeric_limits<size_t>::max() in the event of an overflow where it's not representable in a size_t.
imagesize_t OpenImageIO::ImageSpec::scanline_bytes | ( | ) | const |
Return the number of bytes for each scanline. This will return std::numeric_limits<imagesize_t>::max() in the event of an overflow where it's not representable in an imagesize_t.
void OpenImageIO::ImageSpec::set_format | ( | TypeDesc | fmt | ) |
Set the data format, and as a side effect set quantize & dither to good defaults for that format
bool OpenImageIO::ImageSpec::size_t_safe | ( | ) | const [inline] |
Verify that on this platform, a size_t is big enough to hold the number of bytes (and pixels) in a scanline, a tile, and the whole image. If this returns false, the image is much too big to allocate and read all at once, so client apps beware and check these routines for overflows!
imagesize_t OpenImageIO::ImageSpec::tile_bytes | ( | ) | const |
Return the number of bytes for each a tile of the image. This will return std::numeric_limits<imagesize_t>::max() in the event of an overflow where it's not representable in an imagesize_t.
imagesize_t OpenImageIO::ImageSpec::tile_pixels | ( | ) | const |
Return the number of pixels for a tile. This will return std::numeric_limits<imagesize_t>::max() in the event of an overflow where it's not representable in an imagesize_t.
Index of alpha channel, or -1 if not known.
std::vector<std::string> OpenImageIO::ImageSpec::channelnames |
Names for each channel, e.g., {"R","G","B","A"}
depth of pixel data, >1 indicates a "volume"
Additional attributes.
The above contains all the information that is likely needed for every image file, and common to all formats. Rather than bloat this structure, customize it for new formats, or break back compatibility as we think of new things, we provide extra_attribs as a holder for any other properties of the image. The public functions attribute and find_attribute may be used to access these data. Note, however, that the names and semantics of such extra attributes are plugin-dependent and are not enforced by the imageio library itself.
format of data in each channel N.B., current implementation assumes that all channels are the same data format.
depth of the full (display) window
height of the full (display) window
width of the full (display) window
origin of the full (display) window
origin of the full (display) window
origin of the full (display) window
gamma exponent of the values in the file
height of the pixel data window
Value mapping of color channels.
number of image channels, e.g., 4 for RGBA
quantization of black (0.0) level
dither amplitude for quantization
quantization maximum clamp value
quantization minimum clamp value
quantization of white (1.0) level
tile depth (0 for a non-tiled image, 1 for a non-volume image)
tile height (0 for a non-tiled image)
tile width (0 for a non-tiled image)
width of the pixel data window
origin (upper left corner) of pixel data
Index of depth channel, or -1 if not known.