L_PaintDCCallback

#include "l_bitmap.h"

L_LTDIS_API L_INT L_PaintDCCallback(pCallbackData, pBitmap, pSrc, pSrcClip, pDest, pDestClip, uROP3)

pPAINTCALLBACKDATA pCallbackData;

/* pointer to the structure containing the paint callbacks */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_RECT* pSrc;

/* pointer to the display source rectangle */

L_RECT* pSrcClip;

/* pointer to the display source clipping rectangle */

L_RECT* pDest;

/* pointer to the display destination rectangle */

L_RECT* pDestClip;

/* pointer to the display destination clipping rectangle */

L_UINT32 uROP3;

/* windows ROP code for display */

Displays any image, at any size, to any device context (screen, printer, or memory dc) using custom callbacks. If the display surface has fewer colors than the image, this function dithers the output to that display surface without affecting the actual image data.

Parameter

Description

pCallbackData

Pointer to a structure containing the device context (DC) and the paint callbacks.

pBitmap

Pointer to the bitmap handle referencing the bitmap to paint.

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.

pSrcClip

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.

pDest

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.

pDestClip

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.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Please see the documentation for L_PaintDC for more details on how you use theses rectangle.

If you are using specialized functions painting, refer to those functions' documentation to verify which device contexts are compatible with those functions. For example, some graphics cards with more than 8bits/component display might work only with screen DCs (not memory DCs).

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

LTDIS

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP/Vista, Windows CE.

See Also

Functions:

L_PaintDC, L_PaintRgnDCCallback, L_PaintDCBufferCallback, L_PaintRgnDCBufferCallback, L_PaintDCOverlayCallback

Topics:

Raster Image Functions: Displaying Images

 

Paint Using Custom Callbacks

 

Raster Image Functions: Palettes

 

Handling Palette Changes

 

Raster Image Functions: Using Custom Paint

Example

For complete sample code, please contact LEADTOOLS Technical for a complete sample that paints to a Barco display adapter. This example shows the minimum requirements for painting an image using a custom callback.

L_INT PaintDCCallbackExample(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_PaintDCCallback(&PaintCallbackData, /* Paint Callback 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);

   /* Delete the newly created palette */
   DeleteObject (hOurPalette);

   /* Release the device context */
   ReleaseDC(hWnd, hdc);
   return SUCCESS;
}