Converts image data in a class object's buffer from one color space model to another. The supported models are RGB, YUV, CMYK, CMY, YIQ, HSV, and HLS.
#include "ltwrappr.h"
virtual L_INT LBuffer::ConvertColorSpace(LBufferSrc, nWidth, nFormatSrc, nFormatDst)
The LBuffer object holding the input data.
The number of pixels to be processed.
Format of the source data. There are two possible groups of values. The first group of values is:
Value | Meaning |
---|---|
CCS_RGB | [0x00] RGB color space model (in BGR order). |
CCS_YUV | [0x01] YUV color space model. |
CCS_CMYK | [0x02] CMYK color space model. |
CCS_CMY | [0x06] CMY color space model. |
CCS_YIQ | [0x05] YIQ color space model. |
CCS_HSV | [0x03] HSV color space model. |
CCS_HLS | [0x04] HLS color space model. |
CCS_BGR | [0x0C] BGR color space model. |
CCS_ARGB4 | [0x90] Color space is ARGB4444. |
Value | Meaning |
---|---|
CCS_RGB16 | [0x10] RGB color space model (in BGR order) |
CCS_YUV16 | [0x20] YUV color space model. |
CCS_YIQ16 | [0x30] YIQ color space model. |
CCS_HSV16 | [0x40] HSV color space model. |
CCS_HLS16 | [0x50] HLS color space model. |
CCS_CMY16 | [0x60] CMY color space model. |
CCS_CMYK16 | [0x70] CMYK color space model. |
Format of the output data. There are two possible groups of values. The first group of values is:
Value | Meaning |
---|---|
CCS_RGB | [0x00] RGB color space model (in BGR order). |
CCS_YUV | [0x01] YUV color space model. |
CCS_CMYK | [0x02] CMYK color space model. |
CCS_CMY | [0x06] CMY color space model. |
CCS_YIQ | [0x05] YIQ color space model. |
CCS_HSV | [0x03] HSV color space model. |
CCS_HLS | [0x04] HLS color space model. |
CCS_BGR | [0x0C] BGR color space model. |
CCS_ARGB4 | [0x90] Color space is ARGB4444. |
Value | Meaning |
---|---|
CCS_RGB16 | [0x10] RGB color space model (in BGR order) |
CCS_YUV16 | [0x20] YUV color space model. |
CCS_YIQ16 | [0x30] YIQ color space model. |
CCS_HSV16 | [0x40] HSV color space model. |
CCS_HLS16 | [0x50] HLS color space model. |
CCS_CMY16 | [0x60] CMY color space model. |
CCS_CMYK16 | [0x70] CMYK color space model. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
RGB is commonly used for displaying images on monitors and for storing images in files. YUV and YIQ are used for data that is stored using JPEG compression. CMYK is used when printing images. HSV and HLS are used in applications that let human beings manipulate the color plane values.
Note the following:
The nFormatSrc and nFormatDst must be selected from the same group (the first or second group shown above). The format of data may be:
24 bits per pixel, except CMYK which is 32. In this case the nFormatSrc and nFormatDst must be selected from the first group.
48 bits per pixel except CMYK which is 64. In this case the nFormatSrc and nFormatDst must be selected from the second group.
When using a 48-bit format, the data must be allocated in an integer (short) buffer, but this function's buffer parameters expect unsigned characters. Therefore, when allocating space for data, you should allocate a buffer of integers; then cast the buffer pointer to the appropriate data type when using it as a parameter.
YUV or YIQ data must be always allocated in an integer (short) buffer. Therefore, when allocating space for YUV or YIQ data, you should allocate a buffer of integers; then cast the buffer pointer to the appropriate data type when using it as a parameter.
RGB input data for this function must be 24-bit or 48-bit in BGR order.
Color-plane values for all models of 24 bits, except YUV and YIQ, are scaled from 0 to 255. For example, a hue, which is normally represented as 0-359, is instead scaled to fit the 0-255 range. For YUV or YIQ, color plane values are scaled from 0 to 16383.
The parameter LBufferSrc is passed by reference, and is a required parameter.
This function also supports 12 and 16 - bit grayscale bitmaps. Support for 12 and 16 - bit grayscale images is available only in the Document/Medical toolkits.
Win32, x64.
L_INT LBuffer__ConvertColorSpaceExample()
{
L_INT nRet;
LBitmapBase LeadBitmap;
nRet = LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("image1.cmp"))) ;
if(nRet !=SUCCESS)
return nRet;
LBuffer LeadBuffer(LeadBitmap.GetWidth() * 3);
LBuffer TmpBuffer (LeadBitmap.GetWidth() * 4);
nRet =(L_INT)LeadBitmap.GetRow(&LeadBuffer,0);
if(nRet < 1)
return nRet;
nRet =TmpBuffer.ConvertColorSpace(LeadBuffer,LeadBitmap.GetWidth(), CCS_RGB, CCS_CMYK);
if(nRet !=SUCCESS)
return nRet;
LeadBuffer = TmpBuffer ;
nRet =TmpBuffer.Free() ;
if(nRet !=SUCCESS)
return nRet;
nRet =LeadBuffer.Free() ;
if(nRet !=SUCCESS)
return nRet;
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document