Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6685 Discussions

using ippiAlphaComp with separate RGB and A buffers


Hi - I'm trying to composite images where the RGB and Alpha channels are held in different image buffers.

My app uses windows GDI bitmaps (BGR order) for to hold color information, and a home-built image format to hold a one-byte-per-pixel alpha channel. The alpha is independent from the RGB and needs to be kept separate.

I can pass pointers to my buffers to IPP as Ipp8u for functions expecting 8u_C3R and 8u_C1R.

However ippiAlphaComp seems to work only with 8u_AC4R 

Question 1: could you add a variant of AlphaComp that takes 8u_C3R for RGB plus 8u_C1R for alpha.

... so I gather that I need to interleave the alpha and RGB images... ? convert RGB to RGB_ for the foreground, then copy A into that buffer producing the foreground RGBA, then convert RGB to RGB_ for the background, then do the alpha composite, then unpack everything. YUCK.

Question 2: am I missing something or do I really need to allocate new buffers, interleave them, etc etc?

Question 3: How do I efficiently insert an 8-bit Alpha channel from an 8u_C1R image into just one channel of an 8u_C4R image? I can't find a way.


if pFG is a windows 24-bit BGR image, then....

// convert the FB 24-bit RGB into 32-bit RGB_

Ipp8u* lFG = pFG.GetBitsAddress();  // my DIB wrapper
int FGStep = pFG.GetScanLineWidthBytes();   // my DIB wrapper
int lFG_RGBA_StepBytes = 0;
Ipp8u * lFG_RGBA_Buffer = NULL;
lFG_RGBA_Buffer = (Ipp8u*)ippiMalloc_8u_AC4(lWidth, lHeight, &lFG_RGBA_StepBytes);
// copy RGB into RGBA-sized buffer
ippiCopy_8u_AC4C3R(lFG, FGStep, pFG_RGBA_Buffer, lFG_RGBA_StepBytes, roiSize);

// same for the background

Ipp8u* lBG = pBG.GetBitsAddress();  // my DIB wrapper
int BGStep = pBG.GetScanLineWidthBytes();   // my DIB wrapper
int lBG_RGBA_StepBytes = 0;
Ipp8u * lBG_RGBA_Buffer = NULL;
lBG_RGBA_Buffer = (Ipp8u*)ippiMalloc_8u_AC4(lWidth, lHeight, &lBG_RGBA_StepBytes);
// copy RGB into RGBA-sized buffer
ippiCopy_8u_AC4C3R(lBG, BGStep, pBG_RGBA_Buffer, lBG_RGBA_StepBytes, roiSize);

// get the alpha for the foreground
Ipp8u* lA = pAlpha.GetBitsAddress();  // my DIB wrapper
int AStep = pAlpha.GetScanLineWidthBytes();   // my DIB wrapper

... but now what? Which IPP command will insert lA into lBG_RGBA_Buffer?


Thank you for any guidance you can provide,


0 Kudos
1 Reply

Hi Mike,

You should use

IPPAPI( IppStatus, ippiCopy_8u_C1C4R,
                   ( const Ipp8u* pSrc, int srcStep,
                     Ipp8u* pDst, int dstStep, IppiSize roiSize ))
function - shift pDst pointer to A-channel position and use your A-array as pSrc

regards, Igor

0 Kudos