#include "ltwrappr.h"
L_INT LColor::ConvertToBitmap(pSrcBuf, pBitmap, uStructSize, nWidth, nHeight, nInAlign, nOutAlign);
Converts image data in a buffer from one color conversion model to RGB\BGR, and sets the converted data in a LBitmapBase class object.
Pointer to the buffer that references the input data.
Pointer to LBitmapBase class object that references the converted data.
Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).
Width of pixels to be processed.
Height of pixels to be processed.
Each scanline in the input buffer is a multiple of nInAlign bytes.
Each scanline in the output buffer is a multiple of nOutAlign bytes
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Conversion is done by setting the nActiveMethod value of the CONVERSION_PARAMS structure when calling LColor::Initialize. To change the nActiveMethod value, use LColor::SetConversionParams. Only methods supported by the initialized converter should be specified.
The conversion is done if it was initialized with BGR or RGB Color Spaces as the destination.
Required DLLs and Libraries
L_INT LColor_ConvertToBitmapExample()
{
L_INT nRet;
LColor lClr;
LBitmapBase LeadBitmap; /* Bitmap handle to hold the loaded image. */
LBitmapBase OutBitmap;
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), 0, ORDER_BGR);
if(nRet !=SUCCESS)
return nRet;
LBuffer Input(sizeof(L_UCHAR) * (LeadBitmap.GetMemSize()));
LeadBitmap.GetRowCol(&Input, 0, 0);
L_UCHAR* pInput = (L_UCHAR*)(Input.Lock()); /*input buffer*/
L_INT nWidth = LeadBitmap.GetWidth(); /*pixels width*/
L_INT nHeight = LeadBitmap.GetHeight(); /*pixels height*/
/* direct conversion using built in options */
nRet = lClr.ConvertToBitmap(pInput, &OutBitmap, sizeof(BITMAPHANDLE), nWidth, nHeight, 0, 0);
if(nRet !=SUCCESS)
return nRet;
nRet = OutBitmap.Save (MAKE_IMAGE_PATH(TEXT("Result.BMP")), FILE_BMP, 24, 0, NULL);
if(nRet !=SUCCESS)
return nRet;
//free bitmap
if(LeadBitmap.IsAllocated())
LeadBitmap.Free();
if(OutBitmap.IsAllocated())
OutBitmap.Free();
return SUCCESS;
}