COLORRESCALLBACK Function
#include "l_bitmap.h"
L_INT pEXT_CALLBACK YourFunction (pBitmap, pBuffer, nLines, pUserData)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle*/ |
/* pointer to a buffer of the caller's output data*/ | |
L_INT nLines; |
/* number of lines in the buffer*/ |
/* 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.
See Also
Example
/* This COLORRESCALLBACK function paints the image as the image is processed. */
/**************** Global declarations **************************************/
HPALETTE hpalPaint; /* Paint palette handle */
RECT rLeadDest; /* Destination rectangle for painting */
RECT rLeadSource; /* Source rectangle for painting */
/* 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 */
} IMAGECBPARM;
/*******************************************************************************/
L_INT L_EXPORT EXT_CALLBACK ColorResCallback (pBITMAPHANDLE pBitmap,
L_UCHAR L_FAR *pBuffer, L_INT nLines,
IMAGECBPARM L_FAR* pUserData)
{
/* 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, 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 */
&rLeadSource, /* Source rect - set globally in WM_CREATE */
&rLeadSource, /* Source clip rect - same as source rect */
&rLeadDest, /* Destination rect - set globally in WM_CREATE */
&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 );
}