#include "l_bitmap.h"

L_LTDIS_API L_INT L_PaintDCCMYKArray (hDC, ppBitmapArray, uBitmapArrayCount, pSrc, pClipSrc, pDst, pClipDst, uROP3, hClrHandle);


handle to the target device context

pBITMAPHANDLE * ppBitmapArray;

array of pointers to BITMAPHANDLE handle

L_UINT uBitmapArrayCount;

number of items in the bitmaps array

L_RECT* pSrc;

pointer to the display source rectangle

L_RECT* pClipSrc;

pointer to the display source clipping rectangle

L_RECT* pDst;

pointer to the display destination rectangle

L_RECT* pClipDst;

pointer to the display destination clipping rectangle


windows ROP code for display

L_HANDLE hClrHandle;

optional color conversion handle

Displays an array of CMYK bitmaps, at any size, to any device context (screen, printer, or memory dc).




Handle to a device context, such as a screen, to use as the display surface. The mapping mode of the device context must be MM_TEXT.


Pointer to an array of pointers to the bitmaps that contain each plane. You should have 4 or 5 members in the array, depending on whether you want to paint with alpha channel information.


All the bitmaps must have the same width, height, bits per pixel and palette. uBitmapArrayCount indicates how many pointers are stored in the array. The bitmaps are in this order: C, M, Y, K, Alpha (optional).


Number of bitmaps present in ppBitmapArray.


Pointer to the Windows RECT structure that specifies the part of the bitmap to use as the display source.


The coordinates in the RECT structure are relative to the bitmap. You can pass NULL to use the default, which matches the bitmap.


Pointer to the Windows RECT structure that specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source bitmap has changed.


The coordinates in the RECT structure are relative to the bitmap. You can pass NULL to use the default, which matches the bitmap.


Pointer to the Windows RECT structure that determines how the source rectangle is scaled and how the image is positioned in the device context.


The coordinates in the RECT structure are relative to the device context. There is no default for this parameter. You must specify the RECT structure.


Pointer to the Windows RECT structure that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.


The coordinates in the RECT structure are relative to the device context. You can pass NULL to use the default, which matches the device context. In most cases, however, you should use the rectangle returned by the Windows WM_PAINT message.


The Windows ROP code that determines how the destination rectangle is updated. This parameter takes the same codes as the Windows BitBlt function. For ordinary painting, use SRCCOPY.


Optional color conversion handle used to convert CMYK data to BGR during painting. Pass NULL to let LEADTOOLS use the built-in color conversion functions.


If you pass hClrHandle != NULL and the LTCLR is missing, the function returns the ERROR_INV_COLORSPACE error code.



The function was successful.


LTCLR DLL cannot be loaded.

< 1

An error occurred. Refer to Return Codes.


The data is automatically converted to BGR and dithered (if necessary) without affecting the bitmaps in the array.

The bitmap array is typically created using L_LoadFileCMYKArray.

For more information on how the source and rectangle parameters behave, refer to the function L_PaintDC.

Windows can only paint BGR data. Therefore, it is necessary to convert CMYK data to BGR during the painting process. Notice that the painting of regular bitmaps, which are already BGR, is faster than the painting of CMYK arrays of bitmaps.

The color conversion can be performed using the Color Conversion C API. For more information refer to the Color Conversion Help File. These conversions are accurate, but are slower than the built-in CMYK->RGB conversion formulas.

To use the accurate conversions, create a color handle using L_ClrInit and pass it as hClrHandle.

To use the fast conversions, pass NULL for hClrHandle.

But note that there is a visible difference between passing a real hClrHandle and using NULL for hClrHandle. Also, make sure you create a correct color CMYK->BGR conversion handle.

When the handle hClrHandle is no longer needed, it should be freed by calling L_ClrFree.

Required DLLs and Libraries


LTCLR (if you use hClrHandle)

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.


Win32, x64.

See Also


L_PaintDC, L_PaintDCBufferCallback,L_WindowLevel, L_RectToBitmap, L_RectFromBitmap, L_PaintDCBufferCallback, L_PaintDCCallback, L_PaintDCCMYKArray, L_PaintDCOverlay, L_PaintDCOverlayCallback, L_PaintRgnDC,  L_PaintRgnDCBuffer, L_PaintRgnDCBufferCallback, L_PaintRgnDCCallback, L_PaintRgnDCEffect, L_LoadFileCMYKArray, L_ColorMergeBitmap, L_ColorSeparateBitmap, L_ConvertColorSpace, L_ClrInit, L_ClrFree


Handling CMYK Files as Separate Bitmaps


Raster Image Functions: Displaying Images


Raster Image Functions: Using Custom Paint


Paint Using Custom Callbacks


This example will load and paint an array of CMYK bitmaps. The color conversion is using the accurate (slower) method. The example will not perform any error checking to make the code easier to understand.

static L_INT ClrInit(HANDLE* phClrHandle) 
   CONVERSION_PARAMS convparams;  
   CMYK_PARAMS       CmykParams;  
   memset(&convparams, 0, sizeof(convparams));  
   convparams.uStructSize = sizeof(convparams);  
   CmykParams.uStructSize = sizeof(CMYK_PARAMS);  
   CmykParams.nMask = CMYK_GCR;  
   CmykParams.nGcr_level = 175; /* 17.5 % GCR value */ 
   convparams.pCmykParams = &CmykParams;  
   convparams.nMethod = USE_ICC;  
   convparams.nActiveMethod = USE_ICC;  
   return L_ClrInit (phClrHandle, CCS_CMYK, CCS_BGR, &convparams);  
L_INT PaintDCCMYKArrayExample(L_HWND hWnd) 
   BITMAPHANDLE   BitmapC, BitmapM, BitmapY, BitmapK;  
   pBITMAPHANDLE  CMYKArray[4] = {&BitmapC, &BitmapM, &BitmapY, &BitmapK}; 
   L_UINT         u;  
   HANDLE         hClrHandle; 
   L_INT          nRet; 
   // load CMYK array 
   nRet = L_LoadFileCMYKArray(MAKE_IMAGE_PATH(TEXT("ET\\src_cmyk_image.tif")), CMYKArray, 4, sizeof(BITMAPHANDLE), 8,    LOADFILE_ALLOCATE|LOADFILE_STORE, NULL, NULL, NULL, NULL);  
   if(nRet != SUCCESS) 
      return nRet; 
   HDC hDC = GetDC(hWnd); // get the window DC 
   // set the destination rect to be the same as each plane (100% zoom)  
   RECT  rcDst;  
   SetRect(&rcDst, 0, 0, BitmapC.Width, BitmapC.Height);  
   // create the color conversion handle 
   nRet = ClrInit(&hClrHandle); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = L_PaintDCCMYKArray(hDC, CMYKArray, 4, NULL, NULL, &rcDst, NULL, SRCCOPY, hClrHandle);  
   // free the color conversion handle 
   if(hClrHandle != NULL)  
      L_ClrFree (hClrHandle);  
   // release the DC 
   ReleaseDC(hWnd, hDC);  
   // free the CMYK array allocated by L_LoadFileCMYKArray 
   for(u = 0; u < 4; u++) 
   return nRet; 

Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help