Displays an array of CMYK bitmaps, at any size, to any device context (screen, printer, or memory dc).
#include "l_bitmap.h"
L_LTDIS_API L_INT L_PaintDCCMYKArray (hDC, ppBitmapArray, uBitmapArrayCount, pSrc, pClipSrc, pDst, pClipDst, uROP3, hClrHandle);
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.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
ERROR_LTCLR_MISSING | 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.
Win32, x64.
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("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);
if (nRet != SUCCESS)
return nRet;
// free the color conversion handle
if (hClrHandle != NULL)
nRet = L_ClrFree(hClrHandle);
if (nRet != SUCCESS)
return nRet;
// 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 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