L_PaintDCCMYKArrayCallback

#include "l_bitmap.h"

L_LTDIS_API L_INT L_PaintDCCMYKArrayCallback (pCallbackData, ppBitmapArray, uBitmapArrayCount, pSrc, pClipSrc, pDst, pClipDst, uROP3, hClrHandle);

Displays an array of CMYK bitmaps, at any size, using paint callbacks.

Parameters

pPAINTCALLBACKDATA pCallbackData

Pointer to a structure containing the device context (DC) and the paint callbacks. The mapping mode of the device context must be MM_TEXT.

pBITMAPHANDLE * ppBitmapArray

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).

L_UINT uBitmapArrayCount

Number of bitmaps present in ppBitmapArray.

L_RECT* pSrc

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.

L_RECT* pClipSrc

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.

L_RECT* pDst

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.

L_RECT* pClipDst

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.

L_UINT32 uROP3

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.

L_HANDLE hClrHandle

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.

Returns

Value Meaning
SUCCESS The function was successful.
ERROR_LTCLR_MISSING LTCLR DLL cannot be loaded.
< 1 An error occurred. Refer to Return Codes.

Comments

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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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 PaintDCCMYKArrayCallbackExample(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; 
 
   /* Initialize the paint callback data structure */ 
   PAINTCALLBACKDATA PaintCallbackData; /* Paint Callback data structure */ 
   memset(&PaintCallbackData, 0, sizeof(PaintCallbackData)); 
   PaintCallbackData.uStructSize = sizeof(PAINTCALLBACKDATA); 
   PaintCallbackData.pDisplay = hDC; 
   nRet = L_PaintDCCMYKArrayCallback(&PaintCallbackData, 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++) 
      L_FreeBitmap(CMYKArray[u]); 
 
   return nRet; 
} 

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

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.