Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Raster imaging C++ Class library help

LPaint::PaintDCCMYKArray

Show in webframe

#include "ltwrappr.h"

L_INT LPaint::PaintDCCMYKArray(ppBitmapArray, uBitmapArrayCount, pSrc, pClipSrc, pDst, pClipDst, uROP3, hClrHandle)

pBITMAPHANDLE * ppBitmapArray;

/* array of pointers to BITMAPHANDLE handle */

L_UINT uBitmapArrayCount;

/* number of items in the bitmaps array */

LPRECT pSrc;

/* pointer to the display source rectangle */

LPRECT pClipSrc;

/* pointer to the display source clipping rectangle */

LPRECT pDst;

/* pointer to the display destination rectangle */

LPRECT pClipDst;

/* pointer to the display destination clipping rectangle */

L_UINT32 uROP3;

/* windows ROP code for display */

HANDLE hClrHandle;

/* optional color conversion handle */

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

Parameter

Description

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

uBitmapArrayCount

Number of bitmaps present in ppBitmapArray.

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.

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.

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.

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.

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.

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 ERROR_INV_COLORSPACE error code.

Returns

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

Required DLLs and Libraries

LTDIS

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.

See Also

Functions:

LPaint::PaintDC, LFile::LoadCMYKArray, LBitmap::ColorMerge, LBitmap::ColorSeparate, LBuffer::ConvertColorSpace

Topics:

Handling CMYK Files as Separate Bitmaps

 

Raster Image Functions: Displaying Images

Example

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.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
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;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.