Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

COLORRESCALLBACK Function

Show in webframe

#include "l_bitmap.h"

L_INT pEXT_CALLBACK YourFunction (pBitmap, pBuffer, nLines, pUserData)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UCHAR* pBuffer;

/* pointer to a buffer of the caller's output data */

L_INT nLines;

/* number of lines in the buffer */

L_VOID* pUserData;

/* pointer to additional parameters */

Handles the converted image data that the L_ColorResBitmap function has written to a buffer.

Parameter

Description

pBitmap

The pointer to the bitmap handle referencing the bitmap that contains the image information.

pBuffer

A pointer to a buffer containing one or more lines of output image data that the calling function has already converted.

nLines

The number of lines in the pBuffer buffer.

pUserData

A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of the calling function.)

 

Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This is an optional callback function for additional processing. (The bitmap is modified the same way, whether you provide a callback function or not.) For an explanation of how the callback function is used, refer to L_ColorResBitmap.

Required DLLs and Libraries

LTKRN

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

L_ColorResBitmap

Example

This COLORRESCALLBACK function paints the image as the image is processed.

/* Structure used for the callback function's user data */
typedef struct tagIMAGECBPARM
{
   HWND  hwnd;     /* Current window */
   HDC   hdc;       /* Device context for the current window */
   L_INT nRow;    /* First row in the input buffer */
   HPALETTE hpalPaint; /* Paint palette handle */
   RECT rLeadDest; /* Destination rectangle for painting */ 
   RECT rLeadSource; /* Source rectangle for painting */
} IMAGECBPARM, * LPIMAGECBPARM;

/*******************************************************************************/

L_INT EXT_CALLBACK ColorResCallback (pBITMAPHANDLE pBitmap, 
                                       L_UCHAR  *pBuffer, L_INT nLines, 
                                       L_VOID * pColorResUserData)
{
   LPIMAGECBPARM pUserData = (LPIMAGECBPARM) pColorResUserData;
   /* If this is the first call (row 0), select and realize the palette */
   if( pUserData->nRow == 0 )
   {
         SendMessage (pUserData->hwnd, WM_QUERYNEWPALETTE, 0, 0L);
         SelectPalette( pUserData->hdc, pUserData->hpalPaint, TRUE );
         RealizePalette(pUserData->hdc);
   }

   /* Paint the buffer to the specified device context */

   L_PaintDCBuffer( pUserData->hdc, /* Device context - from function parameter */
                    pBitmap, /* Bitmap handle - from function parameter */
                    &pUserData->rLeadSource, /* Source rect - set globally in WM_CREATE */
                    &pUserData->rLeadSource, /* Source clip rect - same as source rect */
                    &pUserData->rLeadDest, /* Destination rect - set globally in WM_CREATE */
                    &pUserData->rLeadDest, /* Destination clip rect - same as destination rect */
                    SRCCOPY, /* ROP code for normal painting */
                    pBuffer, /* Input buffer - from function parameter */
                    pUserData->nRow, /* First row in buffer - from function parameter */
                    nLines ); /* Number of lines in the buffer - from function parameter */

   /* Increment the current row by the number of lines in the buffer */
   pUserData->nRow += nLines;

   return( SUCCESS );
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.