Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference
A newer version of this document is available. Customers should click here to go to the newest version.
GrayToRGB
Coverts a gray scale image to RGB/BGR by copying luminance component to color components.
Syntax
IppStatus ippiGrayToRGB_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize);
Supported values for mod:
| 8u_C1C3R | 16u_C1C3R | 32f_C1C3R | 
IppStatus ippiGrayToRGB_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, Ipp<datatype> aval);
Supported values for mod:
| 8u_C1C4R | 16u_C1C4R | 32f_C1C4R | 
Include Files
ippcc.h
Domain Dependencies
Headers: ippcore.h, ippvm.h, ipps.h, ippi.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib
Parameters
| pSrc | Pointer to the source image ROI. | 
| srcStep | Distance, in bytes, between the starting points of consecutive lines in the source image. | 
| pDst | Pointer to the destination image ROI. | 
| dstStep | Distance, in bytes, between the starting points of consecutive lines in the destination image. | 
| roiSize | Size of the source and destination ROI, in pixels. | 
| aval | Constant value to create the fourth channel. | 
Description
This function operates with ROI (see Regions of Interest in Intel IPP ).
This function converts a gray scale image to an RGB/BGR image by copying luminance component to color components.
Return Values
| ippStsNoErr | Indicates no error. Any other value indicates an error. | 
| ippStsNullPtrErr | Indicates an error when pSrc or pDst is NULL. | 
| ippStsSizeErr | Indicates an error condition if roiSize has a field with a zero or negative value. | 
Example
The code example below demonstrates how to use the ippiGrayToRGB_8u_C1C4R function.
    const int WIDTH  = 2;
    const int HEIGHT = 1;
    Ipp8u pSrc[WIDTH * HEIGHT] = {
        113,113,
    };
    Ipp8u pDst[WIDTH * HEIGHT * 4];
    int srcStep = WIDTH, dstStep  = WIDTH * 4;
    IppiSize roiSize = {WIDTH, HEIGHT};
    IppStatus status = ippiGrayToRGB_8u_C1C4R(pSrc, srcStep, pDst, dstStep, roiSize, 0xFF);
    if ( status == ippStsNoErr) {
        printf("PASS:\n(%3d %3d %3d %3d), (%3d %3d %3d %3d)\n", pDst[0], pDst[1], pDst[2], pDst[3], pDst[4], pDst[5], pDst[6], pDst[7]);
    }
    else 
        printf("FAIL: status = %d\n", status);
 
    
   Result:
PASS: (113 113 113 255), (113 113 113 255)