L_PaintRgnDCCallback

#include "l_bitmap.h"

L_LTDIS_API L_INT L_PaintRgnDCCallback(pCallbackData, pBitmap, pSrc, pClipSrc, pDst, pClipDst, uROP3)

Paints the bitmap region using paint callbacks. This function works the same as L_PaintDCCallback, except that only the bitmap region is painted.

Parameters

pPAINTCALLBACKDATA pCallbackData

Pointer to a structure containing the device context (DC) and the paint callbacks. The mapping mode of the device context must be MM_TEXT.

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap that has the region.

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

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

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

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

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

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

The HDC you are painting to should stored in the PAINTCALLBACKDATA structure. Please refer to its documentation for details on which GDI functions you can override.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Structures

Topics

Example

This example shows the minimum requirements for painting the current region of a bitmap using the bitmap's palette.

L_INT PaintRgnDCCallbackExample(L_HWND hWnd, pBITMAPHANDLE pBitmap) 
{ 
   L_INT       nRet; 
   HDC         hdc;                    /* Device context for the current window */ 
   RECT        rcLeadDest;             /* Destination rectangle for painting */ 
   HPALETTE    hSavedPalette = NULL;   /* Temporary copy of the current system palette */ 
   HPALETTE    hOurPalette = NULL;     /* The palette that we will use to paint */ 
   PAINTCALLBACKDATA PaintCallbackData;/* Paint callback data structure */ 
 
   /* Get the device context */ 
   hdc = GetDC (hWnd); 
   /* Set the destination rectangle to be the same as the bitmap. 
   Other painting rectangles can take defaults. */ 
   SetRect(&rcLeadDest, 0, 0, BITMAPWIDTH(pBitmap), BITMAPHEIGHT(pBitmap)); 
   /* Create the palette that we will use to paint */ 
   hOurPalette = L_CreatePaintPalette (hdc, pBitmap); 
   /* Select our palette and save the old one */ 
   hSavedPalette = SelectPalette (hdc, hOurPalette, FALSE); 
   /* Realize our palette */ 
   RealizePalette (hdc); 
    
   /* Initialize the paint callback data structure */ 
   memset(&PaintCallbackData, 0, sizeof(PaintCallbackData)); 
   PaintCallbackData.uStructSize = sizeof(PAINTCALLBACKDATA); 
   PaintCallbackData.pDisplay = hdc; 
 
   /* set the paint callbacks for the GDI functions you are overriding here 
 
        PaintCallbackData.pIsCompatibleDC = MyIsCompatibleDC; 
        PaintCallbackData.pStretchDIBits = MyStretchDIBits; 
        etc 
   */ 
 
   /* Paint the image */ 
   nRet = L_PaintRgnDCCallback(&PaintCallbackData, /* Callback data structure */ 
                 pBitmap,     /* Bitmap handle */ 
                 NULL,        /* Default source rectangle */ 
                 NULL,        /* Default source clip area */ 
                 &rcLeadDest, /* Destination rectangle */ 
                 NULL,        /* Default destination clipping rectangle */ 
                 SRCCOPY);    /*  ROP3 code for a Normal Paint */ 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Restore the old palette */ 
   SelectPalette (hdc, hSavedPalette, FALSE); 
   /* Release the device context */ 
   ReleaseDC(hWnd, hdc); 
   return SUCCESS; 
} 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help