COLORRESCALLBACK

#include "l_bitmap.h"

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

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

Parameters

pBITMAPHANDLE pBitmap

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

L_UCHAR* pBuffer

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

L_INT nLines

The number of lines in the pBuffer buffer.

L_VOID* 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

Value Meaning
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

See Also

Functions

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 ); 
} 

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.