L_INT LPaint::PaintDCCMYKArray(ppBitmapArray, uBitmapArrayCount, pSrc, pClipSrc, pDst, pClipDst, uROP3, hClrHandle)
Displays an array of CMYK bitmaps, at any size, to any device context (screen, printer, or memory dc).
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 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 LFile::LoadCMYKArray.
For more information on how the source and rectangle parameters behave, refer to the function LPaint::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++ Class Library. 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.
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.
This example will load all CMYK TIFF file, increase the brightness of the K plane only (which will darken the image) and save the file as CMYK TIFF.
L_INT LPaint__PaintDCCMYKArrayExample(CDC* pdc)
{
L_INT nRet;
FILEINFO FileInfo;
LFile File;
RECT rcDst;
LPaint paint ;
LBitmap CMYKBitmapsArray[4];
pBITMAPHANDLE CMYKHandlesArray[4] = {CMYKBitmapsArray[0].GetHandle(), CMYKBitmapsArray[1].GetHandle(),CMYKBitmapsArray[2].GetHandle(), CMYKBitmapsArray[3].GetHandle()};
File.SetFileName(MAKE_IMAGE_PATH(TEXT("ET\\src_cmyk_image.tif"))) ;
memset(&FileInfo, 0,sizeof(FileInfo)) ;
nRet = File.GetInfo(&FileInfo, sizeof(FileInfo), 0, NULL);
if(nRet != SUCCESS)
{
MessageBox(NULL, TEXT("Invalid source file"), TEXT("Error"), MB_OK);
return nRet;
}
nRet = File.LoadCMYKArray(CMYKHandlesArray, 4, sizeof(BITMAPHANDLE), 8, LOADFILE_ALLOCATE|LOADFILE_STORE, NULL, NULL/*&FileInfo*/);
if(nRet != SUCCESS)
{
MessageBox(NULL, TEXT("LoadCMYKArray failed!"), TEXT("Error"), MB_OK);
return nRet;
}
// set the destination rect to be the same as each plane (100% zoom)
SetRect(&rcDst, 0, 0, CMYKBitmapsArray[0].GetHandle()->Width, CMYKBitmapsArray[0].GetHandle()->Height);
paint.SetDC(pdc->GetSafeHdc()) ;
nRet = paint.PaintDCCMYKArray(CMYKHandlesArray, 4, NULL, NULL, &rcDst, NULL, SRCCOPY, NULL);
if(nRet < 1)
return nRet;
// free the CMYK array allocated by LoadCMYKArray
for(L_INT u = 0; u < 4; u++)
{
L_TCHAR s[_MAX_PATH];
wsprintf(s, MAKE_IMAGE_PATH(TEXT("plane%d.tif")), u);
nRet = CMYKBitmapsArray[u].Save(s, FILE_TIF, 0, 2, 0,NULL);
if(nRet != SUCCESS)
return nRet;
nRet = CMYKBitmapsArray[u].Free();
if(nRet != SUCCESS)
return nRet;
}
MessageBox(NULL, TEXT("Done"), TEXT(""), MB_OK) ;
return SUCCESS;
}
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