PWLib  1.10.10
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends
PColourConverter Class Reference

#include <vconvert.h>

Inheritance diagram for PColourConverter:
PObject PSynonymColour

List of all members.

Public Member Functions

 PColourConverter (const PString &srcColourFormat, const PString &dstColourFormat, unsigned width, unsigned height)
BOOL GetVFlipState ()
void SetVFlipState (BOOL vFlipState)
virtual BOOL SetFrameSize (unsigned width, unsigned height)
virtual BOOL SetSrcFrameSize (unsigned width, unsigned height)
virtual BOOL SetDstFrameSize (unsigned width, unsigned height, BOOL bScale)
const PStringGetSrcColourFormat ()
const PStringGetDstColourFormat ()
PINDEX GetMaxSrcFrameBytes ()
PINDEX GetMaxDstFrameBytes ()
virtual BOOL Convert (const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, PINDEX *bytesReturned=NULL)=0
virtual BOOL Convert (const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, unsigned int srcFrameBytes, PINDEX *bytesReturned=NULL)=0
virtual BOOL ConvertInPlace (BYTE *frameBuffer, PINDEX *bytesReturned=NULL, BOOL noIntermediateFrame=FALSE)
BOOL GetDstFrameSize (unsigned &width, unsigned &height) const
BOOL GetSrcFrameSize (unsigned &width, unsigned &height) const

Static Public Member Functions

static PColourConverterCreate (const PString &srcColourFormat, const PString &dstColourFormat, unsigned width, unsigned height)

Protected Attributes

PString srcColourFormat
PString dstColourFormat
unsigned srcFrameWidth
unsigned srcFrameHeight
unsigned srcFrameBytes
unsigned dstFrameBytes
unsigned dstFrameWidth
unsigned dstFrameHeight
BOOL scaleNotCrop
BOOL verticalFlip
PBYTEArray intermediateFrameStore
struct jdec_private * jdec

Friends

class PColourConverterRegistration

Detailed Description

This class defines a means to convert an image from one colour format to another. It is an ancestor class for the individual formatting functions.


Constructor & Destructor Documentation

PColourConverter::PColourConverter ( const PString srcColourFormat,
const PString dstColourFormat,
unsigned  width,
unsigned  height 
)

Create a new converter.

Parameters:
srcColourFormatName of source colour format
dstColourFormatName of destination colour format
widthWidth of frame
heightHeight of frame

Member Function Documentation

virtual BOOL PColourConverter::Convert ( const BYTE *  srcFrameBuffer,
BYTE *  dstFrameBuffer,
PINDEX *  bytesReturned = NULL 
) [pure virtual]

Convert from one colour format to another. This version will copy the data from one frame buffer to another. An implementation of this function should allow for the case of where srcFrameBuffer and dstFrameBuffer are the same, if the conversion algorithm allows for that to occur without an intermediate frame store.

The function should return FALSE if srcFrameBuffer and dstFrameBuffer are the same and that form pf conversion is not allowed

Parameters:
srcFrameBufferFrame store for source pixels
dstFrameBufferFrame store for destination pixels
bytesReturnedBytes written to dstFrameBuffer

Implemented in PSynonymColour.

virtual BOOL PColourConverter::Convert ( const BYTE *  srcFrameBuffer,
BYTE *  dstFrameBuffer,
unsigned int  srcFrameBytes,
PINDEX *  bytesReturned = NULL 
) [pure virtual]
Parameters:
srcFrameBufferFrame store for source pixels
dstFrameBufferFrame store for destination pixels
bytesReturnedBytes written to dstFrameBuffer

Implemented in PSynonymColour.

virtual BOOL PColourConverter::ConvertInPlace ( BYTE *  frameBuffer,
PINDEX *  bytesReturned = NULL,
BOOL  noIntermediateFrame = FALSE 
) [virtual]

Convert from one colour format to another. This version will copy the data from one frame buffer to the same frame buffer. Not all conversions can do this so an intermediate store and copy may be required. If the noIntermediateFrame parameter is TRUE and the conversion cannot be done in place then the function returns FALSE. If the in place conversion can be done then that parameter is ignored.

Note that the frame should be large enough to take the destination pixels.

Default behaviour calls Convert() from the frameBuffer to itself, and if that returns FALSE then calls it again (provided noIntermediateFrame is FALSE) using an intermediate store, copying the intermediate store back to the original frame store.

Parameters:
frameBufferFrame buffer to translate data
bytesReturnedBytes written to frameBuffer
noIntermediateFrameFlag to use intermediate store
static PColourConverter* PColourConverter::Create ( const PString srcColourFormat,
const PString dstColourFormat,
unsigned  width,
unsigned  height 
) [static]

Create an instance of a colour conversion function. Returns NULL if there is no registered colour converter between the two named formats.

Parameters:
srcColourFormatName of source colour format
dstColourFormatName of destination colour format
widthWidth of frame (used for both src and dst)
heightHeight of frame (used for both src and dst)

Get the destination colour format.

References dstColourFormat.

BOOL PColourConverter::GetDstFrameSize ( unsigned &  width,
unsigned &  height 
) const

Get the output frame size.

Parameters:
widthWidth of destination frame
heightHeight of destination frame

Get the maximum frame size in bytes for destination frames.

Note a particular device may be able to provide variable length frames (eg motion JPEG) so will be the maximum size of all frames.

References dstFrameBytes.

Get the maximum frame size in bytes for source frames.

Note a particular device may be able to provide variable length frames (eg motion JPEG) so will be the maximum size of all frames.

References srcFrameBytes.

Get the source colour format.

References srcColourFormat.

BOOL PColourConverter::GetSrcFrameSize ( unsigned &  width,
unsigned &  height 
) const

Get the input frame size.

Parameters:
widthWidth of source frame
heightHeight of source frame

Get the video conversion vertical flip state

References verticalFlip.

virtual BOOL PColourConverter::SetDstFrameSize ( unsigned  width,
unsigned  height,
BOOL  bScale 
) [virtual]

Set the destination frame size to be used.

Default behaviour sets the dstFrameWidth and dstFrameHeight variables, and the scale / crop preference. It then recalculates the frame buffer size in bytes then returns TRUE if the size was calculated correctly.

Parameters:
widthNew width of target frame
heightNew height of target frame
bScaleTRUE if scaling is preferred over crop
virtual BOOL PColourConverter::SetFrameSize ( unsigned  width,
unsigned  height 
) [virtual]

Set the frame size to be used.

Default behaviour calls SetSrcFrameSize() and SetDstFrameSize().

Parameters:
widthNew width of frame
heightNew height of frame
virtual BOOL PColourConverter::SetSrcFrameSize ( unsigned  width,
unsigned  height 
) [virtual]

Set the source frame size to be used.

Default behaviour sets the srcFrameWidth and srcFrameHeight variables and recalculates the frame buffer size in bytes then returns TRUE if the size was calculated correctly.

Parameters:
widthNew width of frame
heightNew height of frame
void PColourConverter::SetVFlipState ( BOOL  vFlipState) [inline]

Set the video conversion vertical flip state

References verticalFlip.


Friends And Related Function Documentation

friend class PColourConverterRegistration [friend]

Member Data Documentation

Referenced by GetDstColourFormat().

unsigned PColourConverter::dstFrameBytes [protected]

Referenced by GetMaxDstFrameBytes().

unsigned PColourConverter::dstFrameHeight [protected]
unsigned PColourConverter::dstFrameWidth [protected]
struct jdec_private* PColourConverter::jdec [protected]

Referenced by GetSrcColourFormat().

unsigned PColourConverter::srcFrameBytes [protected]

Referenced by GetMaxSrcFrameBytes().

unsigned PColourConverter::srcFrameHeight [protected]
unsigned PColourConverter::srcFrameWidth [protected]

Referenced by GetVFlipState(), and SetVFlipState().


The documentation for this class was generated from the following file: