DD::Image::Format Class Reference

Describes the size and shape of an image. More...

Inherits DD::Image::Box.

List of all members.

Public Member Functions

const char * name () const
 user-visible name of format
void name (const char *n)
 change the name of the format
int width () const
 Width of image file in pixels.
void width (int v)
int height () const
 Height of image file in pixels.
void height (int v)
double pixel_aspect () const
 Ratio of pixel_width/pixel_height.
void pixel_aspect (double v)
 Format ()
 Format (int w, int h, int x, int y, int r, int t, double pa=1)
 Format (int w, int h, double pa=1)
void add (const char *name)
bool is_none () const
void append (Hash &) const
void from_uv (float u, float v, float &X, float &Y) const
void to_uv (float X, float Y, float &u, float &v) const
void from_uv_centre (float u, float v, int &X, int &Y, bool ignore_pixel_aspect=false) const
void to_uv_centre (int X, int Y, float &u, float &v, bool ignore_pixel_aspect=false) const

Static Public Member Functions

static FormatfindExisting (int w, int h, double pixel_aspect=0)
static Formatindex (int i)
static unsigned size ()

Static Public Attributes

static Format None

Detailed Description

Describes the size and shape of an image.

This is the structure returned by Iop::info().format

When an image is written the width and height of the format determine the size of the image file. Data outside this is clipped.

The x,y,r,t rectangle is the "aperture" which is where the image data actually is, the rest is padding or borders. In most formats the box is equal to 0,0,width,height, this is used by film formats such as Academy where a large gap at the left is soundtrack, or for letterboxed images imbedded in larger 4:3 image formats. The primary use of this box is to convert coordinates between formats so that the user's idea of the center and edges of the image is preserved. Some operators also use this to clip drawing or to set the center of projection.

The pixel_aspect is used to make the operators act "square" even if the data isn't. Filters use this to adjust their aspects, and transformations use this to make rotations work.

Though the info() of an Iop will often match either the aperture box or the outside of the format, there is no requirement of this. The data in an image may be larger or smaller than the Format and does not have to intersect it.


Constructor & Destructor Documentation

DD::Image::Format::Format ( ) [inline]

Default constructor puts garbage in all fields.


Member Function Documentation

void Format::add ( const char *  name)

Add this instance to a list of "named" formats. This list is searched by findExisting(). You should not delete this format after doing this. The name can be null in which case Nuke will generate a "640x480" style name for you.

References name().

Referenced by DD::Image::Reader::set_info().

Format * Format::findExisting ( int  w,
int  h,
double  pixel_aspect = 0 
) [static]

Finds the first format with the given size and pixel aspect.

If pixel_aspect is zero then the first match with any pixel_aspect is returned. This is for the common case of files where the size is known but not the pixel aspect, it allows the size to choose the pixel aspect.

References pixel_aspect().

Referenced by DD::Image::Reader::set_info().

Format * Format::index ( int  i) [static]

Return the i'th format known about. i must be between 0 and size().

unsigned Format::size ( ) [static]

Return the number of formats known about.

bool DD::Image::Format::is_none ( ) const [inline]

True if this is None

Referenced by DD::Image::Black::Black(), and DD::Image::Reader::set_info().

void Format::append ( Hash hash) const

Add this format to the hash. Does not include the format name.

References height(), DD::Image::Box::r(), DD::Image::Box::t(), width(), DD::Image::Box::x(), and DD::Image::Box::y().

void DD::Image::Format::from_uv ( float  u,
float  v,
float &  X,
float &  Y 
) const [inline]

Transform a UV coordinate in the range 0-1 into the format's XY range

void DD::Image::Format::to_uv ( float  X,
float  Y,
float &  u,
float &  v 
) const [inline]

Back-transform an XY coordinate in the format's space into UV space.

void DD::Image::Format::from_uv_centre ( float  u,
float  v,
int &  X,
int &  Y,
bool  ignore_pixel_aspect = false 
) const [inline]

Transform a screen centre based UV coordinate in the range 0-1 into the format's XY range

References fast_rint().

void DD::Image::Format::to_uv_centre ( int  X,
int  Y,
float &  u,
float &  v,
bool  ignore_pixel_aspect = false 
) const [inline]

Back-transform an XY coordinate in the format's space into screen centre based UV space.


Member Data Documentation

Format Format::None [static]

The format fields of DD::Image::Iop are initialized to this value, which is a video (640x480) sized image. Most operators will change the initial value.

Referenced by DD::Image::Black::Black(), DD::Image::Iop::Iop(), and DD::Image::Reader::Reader().