Ocean
Ocean::CV::FrameBlender Class Reference

This class implements a frame blender using an alpha channel to blend frames. More...

Data Structures

class  FrameChannels
 Helper class allowing to determine the number of channels of a frame. More...
 
class  SourceOffset
 Helper class allowing to determine the offset that is necessary to access the alpha channel. More...
 
class  TargetOffset
 Helper class allowing to determine the number of channels of the target frame. More...
 

Public Types

enum  AlphaTargetModulation { ATM_UNDEFINED = 0 , ATM_CONSTANT , ATM_BLEND }
 Definition of individual target alpha channel modulation functions. More...
 
typedef void(* BlendFunction) (uint8_t *, const uint8_t)
 Definition of a blend function allowing to apply a more complex blend operation than a simple linear blending for one pixel (and thus for all channels of this pixel). More...
 

Static Public Member Functions

template<bool tTransparentIs0xFF>
static bool blend (const Frame &source, Frame &target, const uint8_t alphaValue, Worker *worker=nullptr)
 Blends two frames with same frame type by application of one unique blending factor for all pixels. More...
 
template<bool tTransparentIs0xFF, AlphaTargetModulation tAlphaTargetModulation>
static bool blend (const Frame &sourceWithAlpha, Frame &target, Worker *worker=nullptr)
 Blends an entire source frame holding an alpha channel with a target frame without an alpha channel. More...
 
template<bool tTransparentIs0xFF, AlphaTargetModulation tAlphaTargetModulation>
static bool blend (const Frame &sourceWithAlpha, Frame &result, const uint8_t *backgroundColor, Worker *worker=nullptr)
 Blends an entire source frame holding an alpha channel with a static background color and creates a new frame without alpha channel. More...
 
template<bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
static bool blend (const Frame &sourceWithAlpha, Frame &target, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, Worker *worker=nullptr)
 Blends a sub-region of a source frame with a target frame without an alpha channel. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannel (const uint8_t *source, uint8_t *target, const uint8_t alphaValue, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
 Blends two 8 bit per channel frames with same frame type by application of one unique blending factor for all pixels. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannel (const uint8_t *source, const uint8_t *alpha, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int alphaPaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
 Blends an entire source and target frame while the alpha channel is provided in a third frame. More...
 
template<unsigned int tChannelsWithAlpha, bool tAlphaAtFront, bool tTargetHasAlpha, bool tTransparentIs0xFF, AlphaTargetModulation tAlphaTargetModulation>
static void blend8BitPerChannel (const uint8_t *sourceWithAlpha, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourceWithAlphaPaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
 Blends an entire source and target frame while the alpha channel is in front of the data channels or behind the data channels. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannel (const uint8_t *alpha, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t *value, const unsigned int alphaPaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
 Blends a target frame with a specified constant value for all pixels, while each pixel might have a different blending factor. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannel (const uint8_t *alpha, uint8_t *target, const unsigned int width, const unsigned int height, const BlendFunction blendFunction, const unsigned int alphaPaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
 Blends a target frame with a specified blending function, while each pixel might have a different blending factor. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannel (const uint8_t *source, const uint8_t *alpha, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int alphaPaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
 Blends a sub-region of a source frame with a target frame while the alpha channel is provided in a third frame with frame size identical to the source frame. More...
 
template<unsigned int tChannelsWithAlpha, bool tAlphaAtFront, bool tTargetHasAlpha, bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
static void blend8BitPerChannel (const uint8_t *sourceWithAlpha, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
 Blends a sub-region of a source frame with a target frame while the alpha channel is in front of the data channels or behind the data channels. More...
 
template<bool tTransparentIs0xFF>
static uint8_t fullTransparent8Bit ()
 Returns the alpha value for a fully transparent pixel. More...
 
template<bool tTransparentIs0xFF>
static uint8_t fullOpaque8Bit ()
 Returns the alpha value for a fully opaque pixel. More...
 
template<bool tTransparentIs0xFF>
static uint8_t alpha8BitToTransparentIs0xFF (const uint8_t alpha)
 Converts a given alpha value so that 0xFF is interpreted as fully transparent. More...
 
template<bool tTransparentIs0xFF>
static uint8_t alpha8BitToOpaqueIs0xFF (const uint8_t alpha)
 Converts a given alpha value so that 0xFF is interpreted as fully opaque. More...
 
template<>
uint8_t fullTransparent8Bit ()
 
template<>
uint8_t alpha8BitToTransparentIs0xFF (const uint8_t alpha)
 
template<>
uint8_t alpha8BitToOpaqueIs0xFF (const uint8_t alpha)
 

Static Protected Member Functions

template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannelSubset (const uint8_t *source, uint8_t *target, const uint8_t alphaValue, const unsigned int width, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
 Blends a subset of two 8 bit per channels frames by application of one unique blending factor for all pixels. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannelSubset (const uint8_t *source, const uint8_t *alpha, uint8_t *target, const unsigned int width, const unsigned int sourcePaddingElements, const unsigned int alphaPaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
 Blends a subset of a source and target frame (each 8 bit per channel) while the alpha channel is provided as a third frame. More...
 
template<unsigned int tChannelsWithAlpha, bool tAlphaAtFront, bool tTargetHasAlpha, bool tTransparentIs0xFF, AlphaTargetModulation tAlphaTargetModulation>
static void blend8BitPerChannelSubset (const uint8_t *sourceWithAlpha, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourceWithAlphaPaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
 Blends a subset of a source and target frame while the alpha channel is in front of the data channels or behind the data channels. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannelSubset (const uint8_t *alpha, uint8_t *target, const unsigned int width, const unsigned int height, const uint8_t *value, const unsigned int alphaPaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
 Blends a subset of a target frame with a specified constant value for all pixels, while each pixel might have a different blending factor. More...
 
template<unsigned int tChannels, bool tTransparentIs0xFF>
static void blend8BitPerChannelSubset (const uint8_t *alpha, uint8_t *target, const unsigned int width, const unsigned int height, const BlendFunction blendFunction, const unsigned int alphaPaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
 Blends a subset of a target frame with a specified blending function, while each pixel might have a different blending factor. More...
 
template<bool tTransparentIs0xFF>
static uint8_t sourceBlendFactor (const uint8_t alpha)
 Returns the blend factor for the source frame depending whether 0xFF is interpreted as transparent or opaque. More...
 
template<bool tTransparentIs0xFF>
static uint8_t targetBlendFactor (const uint8_t alpha)
 Returns the blend factor for the target frame depending whether 0xFF is interpreted as transparent or opaque. More...
 
template<>
uint8_t sourceBlendFactor (const uint8_t alpha)
 
template<>
uint8_t targetBlendFactor (const uint8_t alpha)
 

Detailed Description

This class implements a frame blender using an alpha channel to blend frames.

Member Typedef Documentation

◆ BlendFunction

typedef void(* Ocean::CV::FrameBlender::BlendFunction) (uint8_t *, const uint8_t)

Definition of a blend function allowing to apply a more complex blend operation than a simple linear blending for one pixel (and thus for all channels of this pixel).

If e.g., the target frame holds 3 channels, than all three channels have to be handled by one call of the blend function.
The first parameter provides the target pixel The second parameter provides the target blend factor, with range [0, 255]

Member Enumeration Documentation

◆ AlphaTargetModulation

Definition of individual target alpha channel modulation functions.

Enumerator
ATM_UNDEFINED 

Undefined target alpha channel modulation.

ATM_CONSTANT 

The target alpha channel is constant and is not changed.

ATM_BLEND 

The target alpha channel is blended by alphaResult = alphaTarget + alphaSource * (1 - alphaTarget).

Member Function Documentation

◆ alpha8BitToOpaqueIs0xFF() [1/2]

template<bool tTransparentIs0xFF>
uint8_t Ocean::CV::FrameBlender::alpha8BitToOpaqueIs0xFF ( const uint8_t  alpha)
inlinestatic

Converts a given alpha value so that 0xFF is interpreted as fully opaque.

Parameters
alphaThe alpha value that will be converted
Template Parameters
tTransparentIs0xFFTrue, if the given alpha is defined so that 0xFF is interpreted as fully transparent
Returns
Resulting converted alpha value

◆ alpha8BitToOpaqueIs0xFF() [2/2]

template<>
uint8_t Ocean::CV::FrameBlender::alpha8BitToOpaqueIs0xFF ( const uint8_t  alpha)
inlinestatic

◆ alpha8BitToTransparentIs0xFF() [1/2]

template<bool tTransparentIs0xFF>
uint8_t Ocean::CV::FrameBlender::alpha8BitToTransparentIs0xFF ( const uint8_t  alpha)
inlinestatic

Converts a given alpha value so that 0xFF is interpreted as fully transparent.

Parameters
alphaThe alpha value that will be converted
Template Parameters
tTransparentIs0xFFTrue, if the given alpha is defined so that 0xFF is interpreted as fully transparent
Returns
Resulting converted alpha value

◆ alpha8BitToTransparentIs0xFF() [2/2]

template<>
uint8_t Ocean::CV::FrameBlender::alpha8BitToTransparentIs0xFF ( const uint8_t  alpha)
inlinestatic

◆ blend() [1/4]

template<bool tTransparentIs0xFF>
bool Ocean::CV::FrameBlender::blend ( const Frame source,
Frame target,
const uint8_t  alphaValue,
Worker worker = nullptr 
)
static

Blends two frames with same frame type by application of one unique blending factor for all pixels.

The blend function is defined as follows:

tTransparentIs0xFF == true:     targetPixel = sourcePixel * (0xFF - alpha)  +   targetPixel *     alpha
tTransparentIs0xFF == false:    targetPixel = sourcePixel *     alpha       +   targetPixel * (0xFF - alpha)
Parameters
sourceThe source frame that is blended with the target frame, must be valid
targetThe target frame that receives the blending result from source and target pixels, this frame must have the same frame format as the source frame, must be valid
alphaValueBlending factor for all pixels, with range [0, 255]
workerOptional worker object to distribute the computation
Returns
True, if succeeded
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ blend() [2/4]

template<bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
bool Ocean::CV::FrameBlender::blend ( const Frame sourceWithAlpha,
Frame result,
const uint8_t *  backgroundColor,
Worker worker = nullptr 
)
static

Blends an entire source frame holding an alpha channel with a static background color and creates a new frame without alpha channel.

An alpha value of 0xFF may specifies a fully transparent source pixel or may specify a fully opaque source pixel.

Parameters
sourceWithAlphaSource frame with alpha channel
resultThe resulting frame
backgroundColorThe static background color for the resulting frame, ensure that the given buffer is large enough for the resulting pixel format (the source pixel format without alpha channel)
workerOptional worker object to distribute the computation
Returns
True, if succeeded
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent value
tAlphaTargetModulationThe target alpha channel modulation function

◆ blend() [3/4]

template<bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
bool Ocean::CV::FrameBlender::blend ( const Frame sourceWithAlpha,
Frame target,
const unsigned int  sourceLeft,
const unsigned int  sourceTop,
const unsigned int  targetLeft,
const unsigned int  targetTop,
const unsigned int  width,
const unsigned int  height,
Worker worker = nullptr 
)
static

Blends a sub-region of a source frame with a target frame without an alpha channel.

An alpha value of 0xFF may specifies a fully transparent source pixel or may specify a fully opaque source pixel.
The pixel format of the source frame must match to the pixel format of the target frame.
Valid combinations of pixel formats are e.g. (FORMAT_RGBA32, FORMAT_RGBA32) or (FORMAT_RGBA32, FORMAT_RGB24) or (FORMAT_ABGR32, FORMAT_ABGR32) or (FORMAT_ABGR32, FORMAT_BGR24).

Parameters
sourceWithAlphaSource frame with alpha channel, must be valid
targetThe target frame with or without alpha channel, if this frame has an alpha channel this channel will be untouched, must be valid
sourceLeftHorizontal start position inside the source frame, with range [0, sourceWidth)
sourceTopVertical start position inside the source frame, with range [0, sourceHeight)
targetLeftHorizontal start position inside the target frame, with range [0, targetWidth)
targetTopVertical start position inside the target frame, with range [0, targetHeight)
widthThe width of the blending sub-region in pixel, with range [1, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
heightThe height of the blending sub-region in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
workerOptional worker object to distribute the computation
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent
tAlphaTargetModulationThe target alpha channel modulation function

◆ blend() [4/4]

template<bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
bool Ocean::CV::FrameBlender::blend ( const Frame sourceWithAlpha,
Frame target,
Worker worker = nullptr 
)
static

Blends an entire source frame holding an alpha channel with a target frame without an alpha channel.

An alpha value of 0xFF may specifies a fully transparent source pixel or may specify a fully opaque source pixel.
Both frames must have the same frame dimension and pixel origin.
Further, the pixel format of the source frame must match to the pixel format of the target frame.
Valid combinations of pixel formats are e.g. (FORMAT_RGBA32, FORMAT_RGBA32) or (FORMAT_RGBA32, FORMAT_RGB24) or (FORMAT_ABGR32, FORMAT_ABGR32) or (FORMAT_ABGR32, FORMAT_BGR24).

Parameters
sourceWithAlphaSource frame with alpha channel
targetThe target frame with or without alpha channel, if this frame has an alpha channel this channel will be untouched
workerOptional worker object to distribute the computation
Returns
True, if succeeded
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent value
tAlphaTargetModulationThe target alpha channel modulation function

◆ blend8BitPerChannel() [1/7]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannel ( const uint8_t *  alpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const BlendFunction  blendFunction,
const unsigned int  alphaPaddingElements,
const unsigned int  targetPaddingElements,
Worker worker = nullptr 
)
inlinestatic

Blends a target frame with a specified blending function, while each pixel might have a different blending factor.

Parameters
alphaThe alpha frame defining the target blending factor that is applied for each pixel, must be valid
targetThe target frame without alpha channel that will be blended with the constant value parameter, must be valid
widthThe width of the target (and alpha) frame in pixel, with range [1, infinity)
heightThe height of the target (and alpha) frame in pixel, with range [1, infinity)
blendFunctionBlending function allowing to apply a more complex blending function than a simple linear blending, the blend function will receive 0x00 for opaque pixels and 0xFF for transparent pixels as blend factor
alphaPaddingElementsThe number of padding elements at the end of each alpha frame row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target frame row, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Template Parameters
tChannelsNumber of channels of both data frame (without any alpha channel)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ blend8BitPerChannel() [2/7]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannel ( const uint8_t *  alpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const uint8_t *  value,
const unsigned int  alphaPaddingElements,
const unsigned int  targetPaddingElements,
Worker worker = nullptr 
)
inlinestatic

Blends a target frame with a specified constant value for all pixels, while each pixel might have a different blending factor.

Parameters
alphaThe alpha frame defining the value blending factor that is applied for each pixel, must be valid
targetThe target frame without alpha channel that will be blended with the constant value parameter, must be valid
widthThe width of the target (and alpha) frame in pixel, with range [1, infinity)
heightThe height of the target (and alpha) frame in pixel, with range [1, infinity)
valueConstant blending value that is used for each pixel, must be valid
alphaPaddingElementsThe number of padding elements at the end of each alpha frame row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target frame row, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Template Parameters
tChannelsNumber of channels of both data frame (without any alpha channel)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ blend8BitPerChannel() [3/7]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannel ( const uint8_t *  source,
const uint8_t *  alpha,
uint8_t *  target,
const unsigned int  sourceWidth,
const unsigned int  sourceHeight,
const unsigned int  targetWidth,
const unsigned int  targetHeight,
const unsigned int  sourceLeft,
const unsigned int  sourceTop,
const unsigned int  targetLeft,
const unsigned int  targetTop,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  alphaPaddingElements,
const unsigned int  targetPaddingElements,
Worker worker = nullptr 
)
inlinestatic

Blends a sub-region of a source frame with a target frame while the alpha channel is provided in a third frame with frame size identical to the source frame.

Parameters
sourceThe source frame without alpha channel, must be valid
alphaThe alpha frame defining the alpha channel connected with the source frame, must be valid
targetThe target frame without alpha channel, must be valid
sourceWidthWidth of the source (and alpha) frame in pixel, with range [1, infinity)
sourceHeightHeight of the source (and alpha) frame in pixel, with range [1, infinity)
targetWidthWidth of the target frame in pixel, with range [1, infinity)
targetHeightHeight of the target frame in pixel, with range [1, infinity)
sourceLeftHorizontal start position inside the source frame, with range [0, sourceWidth)
sourceTopVertical start position inside the source frame, with range [0, sourceHeight)
targetLeftHorizontal start position inside the target frame, with range [0, targetWidth)
targetTopVertical start position inside the target frame, with range [0, targetHeight)
widthThe width of the blending sub-region in pixel, with range [1, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
heightThe height of the blending sub-region in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
sourcePaddingElementsThe number of padding elements at the end of each row in the source frame, in elements, with range [0, infinity)
alphaPaddingElementsThe number of padding elements at the end of each row in the alpha frame, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each row in the target frame, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Template Parameters
tChannelsNumber of channels of both data frame (without any alpha channel)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ blend8BitPerChannel() [4/7]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannel ( const uint8_t *  source,
const uint8_t *  alpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  alphaPaddingElements,
const unsigned int  targetPaddingElements,
Worker worker = nullptr 
)
inlinestatic

Blends an entire source and target frame while the alpha channel is provided in a third frame.

tTransparentIs0xFF == true:     targetPixel = sourcePixel * (0xFF - alphaPixel)  +   targetPixel *     alphaPixel
tTransparentIs0xFF == false:    targetPixel = sourcePixel *     alphaPixel       +   targetPixel * (0xFF - alphaPixel)
Parameters
sourceThe source frame without alpha channel, which is blended with the target frame, must be valid
alphaThe alpha frame with defining one alpha blending factor for each pixel, must be valid
targetThe target frame without alpha channel, must be valid
widthThe width of both frames in pixel, with range [1, infinity)
heightThe height of the both frames in pixel, with range [1, infinity)
sourcePaddingElementsThe optional number of padding elements at the end of each source row, in elements, with range [0, infinity)
alphaPaddingElementsThe optional number of padding elements at the end of each source row, in elements, with range [0, infinity)
targetPaddingElementsThe optional number of padding elements at the end of each target row, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Template Parameters
tChannelsNumber of channels of both frames (without any alpha channel), with range [1, infinity)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent; False, if 0x00 is interpreted as fully transparent

◆ blend8BitPerChannel() [5/7]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannel ( const uint8_t *  source,
uint8_t *  target,
const uint8_t  alphaValue,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  targetPaddingElements,
Worker worker = nullptr 
)
inlinestatic

Blends two 8 bit per channel frames with same frame type by application of one unique blending factor for all pixels.

The blend function is defined as follows:

tTransparentIs0xFF == true:     targetPixel = sourcePixel * (0xFF - alpha)  +   targetPixel *     alpha
tTransparentIs0xFF == false:    targetPixel = sourcePixel *     alpha       +   targetPixel * (0xFF - alpha)
Parameters
sourceThe source frame that is blended with the target frame, must be valid
targetThe target frame that receives the blending result from source and target pixels, this frame must have the same frame format as the source frame, must be valid
alphaValueThe blending factor for all pixels, with range [0, 255]
widthThe width of both frames in pixel, with range [1, infinity)
heightThe height of the both frames in pixel, with range [1, infinity)
sourcePaddingElementsThe optional number of padding elements at the end of each source row, in elements, with range [0, infinity)
targetPaddingElementsThe optional number of padding elements at the end of each target row, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Template Parameters
tChannelsNumber of channels of both frames (without any alpha channel), with range [1, infinity)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent; False, if 0x00 is interpreted as fully transparent

◆ blend8BitPerChannel() [6/7]

template<unsigned int tChannelsWithAlpha, bool tAlphaAtFront, bool tTargetHasAlpha, bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
void Ocean::CV::FrameBlender::blend8BitPerChannel ( const uint8_t *  sourceWithAlpha,
uint8_t *  target,
const unsigned int  sourceWidth,
const unsigned int  sourceHeight,
const unsigned int  targetWidth,
const unsigned int  targetHeight,
const unsigned int  sourceLeft,
const unsigned int  sourceTop,
const unsigned int  targetLeft,
const unsigned int  targetTop,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourcePaddingElements,
const unsigned int  targetPaddingElements,
Worker worker = nullptr 
)
inlinestatic

Blends a sub-region of a source frame with a target frame while the alpha channel is in front of the data channels or behind the data channels.

Parameters
sourceWithAlphaSource frame with alpha channel, must be valid
targetThe target frame which may also hold an alpha channel depending on tTargetHasAlpha, must be valid
sourceWidthWidth of the source frame in pixel, with range [1, infinity)
sourceHeightHeight of the source frame in pixel, with range [1, infinity)
targetWidthWidth of the target frame in pixel, with range [1, infinity)
targetHeightHeight of the target frame in pixel, with range [1, infinity)
sourceLeftHorizontal start position inside the source frame, with range [0, sourceWidth)
sourceTopVertical start position inside the source frame, with range [0, sourceHeight)
targetLeftHorizontal start position inside the target frame, with range [0, targetWidth)
targetTopVertical start position inside the target frame, with range [0, targetHeight)
widthThe width of the blending sub-region in pixel, with range [1, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
heightThe height of the blending sub-region in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
sourcePaddingElementsThe number of padding elements at the end of each row in the source frame, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each row in the target frame, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Template Parameters
tChannelsWithAlphaNumber of channels in the source frame (including the alpha channel)
tAlphaAtFrontTrue, if the alpha channel is in the front of the data channels
tTargetHasAlphaTrue, if not only the source frame holds an alpha channel but also the target frame, however values in a target alpha channel will be untouched
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent
tAlphaTargetModulationThe target alpha channel modulation function

◆ blend8BitPerChannel() [7/7]

template<unsigned int tChannelsWithAlpha, bool tAlphaAtFront, bool tTargetHasAlpha, bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
void Ocean::CV::FrameBlender::blend8BitPerChannel ( const uint8_t *  sourceWithAlpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourceWithAlphaPaddingElements,
const unsigned int  targetPaddingElements,
Worker worker = nullptr 
)
inlinestatic

Blends an entire source and target frame while the alpha channel is in front of the data channels or behind the data channels.

Parameters
sourceWithAlphaSource frame with alpha channel, must be valid
targetThe target frame which may also hold an alpha channel depending on tTargetHasAlpha, must be valid
widthThe width of both frames in pixel, with range [1, infinity)
heightThe height of both frames in pixel, with range [1, infinity)
sourceWithAlphaPaddingElementsThe number of padding elements at the end of each source row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target row, in elements, with range [0, infinity)
workerOptional worker object to distribute the computation
Template Parameters
tChannelsWithAlphaNumber of channels in the source frame (including the alpha channel)
tAlphaAtFrontTrue, if the alpha channel is in the front of the data channels
tTargetHasAlphaTrue, if not only the source frame holds an alpha channel but also the target frame, however values in a target alpha channel will be untouched
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent
tAlphaTargetModulationThe target alpha channel modulation function

◆ blend8BitPerChannelSubset() [1/5]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannelSubset ( const uint8_t *  alpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const BlendFunction  blendFunction,
const unsigned int  alphaPaddingElements,
const unsigned int  targetPaddingElements,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Blends a subset of a target frame with a specified blending function, while each pixel might have a different blending factor.

Parameters
alphaThe alpha frame defining the target blending factor that is applied for each pixel
targetThe target frame without alpha channel that will be blended with the constant value parameter
widthThe width of the target (and alpha) frame in pixel, with range [1, infinity)
heightThe height of the target (and alpha) frame in pixel, with range [1, infinity)
blendFunctionBlending function allowing to apply a more complex blending function than a simple linear blending, the blend function will receive 0x00 for opaque pixels and 0xFF for transparent pixels as blend factor
alphaPaddingElementsThe optional number of padding elements at the end of each alpha row, in elements, with range [0, infinity)
targetPaddingElementsThe optional number of padding elements at the end of each target row, in elements, with range [0, infinity)
firstRowFirst row of the sub-region to be handled, with range [0, height - 1]
numberRowsNumber of rows of the sub-region to be handled, with range [1, height - firstRow]
Template Parameters
tChannelsNumber of channels of both data frame (without any alpha channel), with range [1, infinity)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ blend8BitPerChannelSubset() [2/5]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannelSubset ( const uint8_t *  alpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const uint8_t *  value,
const unsigned int  alphaPaddingElements,
const unsigned int  targetPaddingElements,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Blends a subset of a target frame with a specified constant value for all pixels, while each pixel might have a different blending factor.

Parameters
alphaThe alpha frame defining the value blending factor that is applied for each pixel
targetThe target frame without alpha channel that will be blended with the constant value parameter
widthThe width of the target (and alpha) frame in pixel, with range [1, infinity)
heightThe height of the target (and alpha) frame in pixel, with range [1, infinity)
valueConstant blending value that is used for each pixel
alphaPaddingElementsThe number of padding elements at the end of each alpha frame row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target frame row, in elements, with range [0, infinity)
firstRowFirst row to be handled, with range [0, height - 1]
numberRowsNumber of rows to be handled, with range [1, height - firstRow]
Template Parameters
tChannelsNumber of channels of both data frame (without any alpha channel), with range [1, infinity)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ blend8BitPerChannelSubset() [3/5]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannelSubset ( const uint8_t *  source,
const uint8_t *  alpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  sourcePaddingElements,
const unsigned int  alphaPaddingElements,
const unsigned int  targetPaddingElements,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Blends a subset of a source and target frame (each 8 bit per channel) while the alpha channel is provided as a third frame.

Parameters
sourceThe source frame that is blended with the target frame, must be valid
alphaThe alpha frame with defining one alpha blending factor for each pixel, must be valid
targetThe target frame that receives the blending result from source and target pixels, this frame must have the same frame format as the source frame, must be valid
widthThe width of all frames, in pixel, with range [1, infinity)
sourcePaddingElementsThe optional number of padding elements at the end of each source row, in elements, with range [0, infinity)
alphaPaddingElementsThe optional number of padding elements at the end of each alpha row, in elements, with range [0, infinity)
targetPaddingElementsThe optional number of padding elements at the end of each target row, in elements, with range [0, infinity)
firstRowThe first row to be handled, with range [0, height - 1]
numberRowsThe number of rows to be handled, with range [1, height - firstRow]
Template Parameters
tChannelsNumber of channels of both data frame (without any alpha channel), with range [1, infinity)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent; False, if 0x00 is interpreted as fully transparent

◆ blend8BitPerChannelSubset() [4/5]

template<unsigned int tChannels, bool tTransparentIs0xFF>
void Ocean::CV::FrameBlender::blend8BitPerChannelSubset ( const uint8_t *  source,
uint8_t *  target,
const uint8_t  alphaValue,
const unsigned int  width,
const unsigned int  sourcePaddingElements,
const unsigned int  targetPaddingElements,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Blends a subset of two 8 bit per channels frames by application of one unique blending factor for all pixels.

Parameters
sourceThe source frame that is blended with the target frame, must be valid
targetThe target frame that receives the blending result from source and target pixels, this frame must have the same frame format as the source frame, must be valid
alphaValueThe blending factor for all pixels, with range [0, 255]
widthThe width of both frames in pixel, with range [1, infinity)
sourcePaddingElementsThe optional number of padding elements at the end of each source row, in elements, with range [0, infinity)
targetPaddingElementsThe optional number of padding elements at the end of each target row, in elements, with range [0, infinity)
firstRowFirst row to be handled, with range [0, height - 1]
numberRowsNumber of rows to be handled, with range [1, height - firstRow]
Template Parameters
tChannelsNumber of channels of both data frame (without any alpha channel), with range [1, infinity)
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent; False, if 0x00 is interpreted as fully transparent

◆ blend8BitPerChannelSubset() [5/5]

template<unsigned int tChannelsWithAlpha, bool tAlphaAtFront, bool tTargetHasAlpha, bool tTransparentIs0xFF, FrameBlender::AlphaTargetModulation tAlphaTargetModulation>
void Ocean::CV::FrameBlender::blend8BitPerChannelSubset ( const uint8_t *  sourceWithAlpha,
uint8_t *  target,
const unsigned int  width,
const unsigned int  height,
const unsigned int  sourceWithAlphaPaddingElements,
const unsigned int  targetPaddingElements,
const unsigned int  firstRow,
const unsigned int  numberRows 
)
staticprotected

Blends a subset of a source and target frame while the alpha channel is in front of the data channels or behind the data channels.

Parameters
sourceWithAlphaSource frame with alpha channel, must be valid
targetThe target frame which may also hold an alpha channel depending on tTargetHasAlpha, must be valid
widthThe width of both frames in pixel, with range [1, infinity)
heightThe height of both frames in pixel, with range [1, infinity)
sourceWithAlphaPaddingElementsThe number of padding elements at the end of each source row, in elements, with range [0, infinity)
targetPaddingElementsThe number of padding elements at the end of each target row, in elements, with range [0, infinity)
firstRowFirst row to be handled, with range [0, height - 1]
numberRowsNumber of rows to be handled, with range [1, height - firstRow]
Template Parameters
tChannelsWithAlphaNumber of channels in the source frame (including the alpha channel), with range [2, infinity)
tAlphaAtFrontTrue, if the alpha channel is in the front of the data channels
tTargetHasAlphaTrue, if not only the source frame holds an alpha channel but also the target frame, however values in a target alpha channel will be untouched
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent
tAlphaTargetModulationThe target alpha channel modulation function

◆ fullOpaque8Bit()

template<bool tTransparentIs0xFF>
uint8_t Ocean::CV::FrameBlender::fullOpaque8Bit
inlinestatic

Returns the alpha value for a fully opaque pixel.

Returns
Fully opaque alpha value
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ fullTransparent8Bit() [1/2]

template<bool tTransparentIs0xFF>
uint8_t Ocean::CV::FrameBlender::fullTransparent8Bit
inlinestatic

Returns the alpha value for a fully transparent pixel.

Returns
Fully transparent alpha value
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent

◆ fullTransparent8Bit() [2/2]

template<>
uint8_t Ocean::CV::FrameBlender::fullTransparent8Bit ( )
inlinestatic

◆ sourceBlendFactor() [1/2]

template<bool tTransparentIs0xFF>
uint8_t Ocean::CV::FrameBlender::sourceBlendFactor ( const uint8_t  alpha)
inlinestaticprotected

Returns the blend factor for the source frame depending whether 0xFF is interpreted as transparent or opaque.

Parameters
alphaThe alpha value for which the blending factor is returned, with range [0, 255]
Returns
Resulting blending factor, with range [0, 255]
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
See also
targetBlendFactor().

◆ sourceBlendFactor() [2/2]

template<>
uint8_t Ocean::CV::FrameBlender::sourceBlendFactor ( const uint8_t  alpha)
inlinestaticprotected

◆ targetBlendFactor() [1/2]

template<bool tTransparentIs0xFF>
uint8_t Ocean::CV::FrameBlender::targetBlendFactor ( const uint8_t  alpha)
inlinestaticprotected

Returns the blend factor for the target frame depending whether 0xFF is interpreted as transparent or opaque.

Parameters
alphaThe alpha value for which the blending factor is returned, with range [0, 255]
Returns
Resulting blending factor, with range [0, 255]
Template Parameters
tTransparentIs0xFFTrue, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
See also
sourceBlendFactor().

◆ targetBlendFactor() [2/2]

template<>
uint8_t Ocean::CV::FrameBlender::targetBlendFactor ( const uint8_t  alpha)
inlinestaticprotected

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