All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::VideoImage Class Reference

An image class to be used with video IO. More...

#include <Radiant/VideoImage.hpp>

Classes

class  Plane
 Holds the data for one image plane. More...
 

Public Member Functions

bool allocateMemory (ImageFormat fmt, int w, int h)
 Allocates memory and sets the image format. More...
 
bool allocateMemory (const VideoImage &that)
 Allocates memory and sets the image format, based on another image. More...
 
bool copyData (const VideoImage &that)
 Copies the image data. More...
 
void freeMemory ()
 Free memory on all the planes.
 
Nimble::Vector2i geometry () const
 Returns the pixel dimensions of the image. More...
 
int height () const
 The height of the image. More...
 
int pixels () const
 The number of pixels in the image. More...
 
void reset ()
 Resets the image.
 
void setFormatBGR ()
 Sets the image format to interleaved BGR.
 
void setFormatBGRA ()
 Sets the image format to interleaved BGRA.
 
void setFormatRGB ()
 Sets the image format to interleaved RGB.
 
void setFormatRGB24 ()
 Sets the image format to planar RGB24.
 
void setFormatRGBA ()
 Sets the image format to interleaved RGB.
 
void setFormatYUV420 ()
 Sets the image format to interleaved YUV 420.
 
void setFormatYUV420P ()
 Sets the image format to planar YUV 420.
 
void setFormatYUV422P ()
 Sets the image format to planar YUV 422.
 
unsigned size () const
 Returns the size of the image data in bytes. More...
 
 VideoImage (ImageFormat fmt=IMAGE_UNKNOWN, int w=0, int h=0)
 Constructs a new video image. More...
 
int width () const
 The width of the image. More...
 
void zero ()
 Fill the image with 0.
 
 ~VideoImage ()
 Destructor.
 

Static Public Member Functions

static const char * formatName (ImageFormat fmt)
 Returns a readable name of a given image format. More...
 
static Nimble::Vector2i planeSize (ImageFormat fmt, int w, int h, int plane)
 Returns the size of an image plane in bytes. More...
 

Public Attributes

ImageFormat m_format
 Image format.
 
int m_height
 Height of the image.
 
Plane m_planes [4]
 Plane information.
 
int m_width
 Width of the image.
 

Detailed Description

An image class to be used with video IO.

This image class is used to package planar and interleaved RGB, YUV and grayscale, with or without alpha channel. A typical use case for this class is the transfer of video frames between video codec and the application.

An image is composed of planes that contain the actual image data.

Note
By default this class does not do any memory management, which is left to the application. There are memory management functions that can be used if you want.

Constructor & Destructor Documentation

Radiant::VideoImage::VideoImage ( ImageFormat  fmt = IMAGE_UNKNOWN,
int  w = 0,
int  h = 0 
)
inline

Constructs a new video image.

Parameters
fmtFormat of the image
wWidth of the image
hHeight of the image

Member Function Documentation

bool Radiant::VideoImage::allocateMemory ( ImageFormat  fmt,
int  w,
int  h 
)

Allocates memory and sets the image format.

Parameters
fmtImage format
wimage width
himage height
Returns
true if allocation was successful
bool Radiant::VideoImage::allocateMemory ( const VideoImage that)
inline

Allocates memory and sets the image format, based on another image.

This function can be used when preparing to copy contents from

from another image.

Parameters
thatVideoImage used as template for the new width, height and format settings
Returns
true if allocation was successful
bool Radiant::VideoImage::copyData ( const VideoImage that)

Copies the image data.

The image format, image size and data

buffers should be set correctly before calling this method.

Parameters
thatVideoImage to copy data from
Returns
true if copy was successful
static const char* Radiant::VideoImage::formatName ( ImageFormat  fmt)
static

Returns a readable name of a given image format.

Parameters
fmtFormat of the image
Returns
Name of the format
Nimble::Vector2i Radiant::VideoImage::geometry ( ) const
inline

Returns the pixel dimensions of the image.

Returns
Number of pixels in the image
int Radiant::VideoImage::height ( ) const
inline

The height of the image.

Returns
Height of the image
int Radiant::VideoImage::pixels ( ) const
inline

The number of pixels in the image.

Returns
Number of pixels in the image
static Nimble::Vector2i Radiant::VideoImage::planeSize ( ImageFormat  fmt,
int  w,
int  h,
int  plane 
)
static

Returns the size of an image plane in bytes.

Parameters
fmtFormat of the image
wWidth of the plane
hHeight of the plane
unsigned Radiant::VideoImage::size ( ) const
inline

Returns the size of the image data in bytes.

Returns
Number of bytes
int Radiant::VideoImage::width ( ) const
inline

The width of the image.

Returns
Width of the image