LColor::ConvertToBitmap

Summary

Converts image data in a buffer from one color conversion model to RGB\BGR, and sets the converted data in a LBitmapBase class object.

Syntax

#include "ltwrappr.h"

L_INT LColor::ConvertToBitmap(pSrcBuf, pBitmap, uStructSize, nWidth, nHeight, nInAlign, nOutAlign);

Parameters

L_UCHAR * pSrcBuf

Pointer to the buffer that references the input data.

LBitmapBase * pBitmap

Pointer to LBitmapBase class object that references the converted data.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).

L_INT nWidth

Width of pixels to be processed.

L_INT nHeight

Height of pixels to be processed.

L_INT nInAlign

Each scanline in the input buffer is a multiple of nInAlign bytes.

L_INT nOutAlign

Each scanline in the output buffer is a multiple of nOutAlign bytes

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

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

See Also

Functions

Topics

Example

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; 
} 
Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Color Conversion C++ Class Library Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.