L_PaintRgnDCBuffer

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_PaintRgnDCBuffer (hDC, pBitmap, pSrc, pClipSrc, pDst, pClipDst, uROP3, pBuffer, nRow, nCount)

HDC hDC;

/* handle to the target device context */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

LPRECT pSrc;

/* pointer to the display source rectangle */

LPRECT pClipSrc;

/* pointer to the display source clipping rectangle */

LPRECT pDst;

/* pointer to the display destination rectangle */

LPRECT pClipDst;

/* pointer to the display destination clipping rectangle */

L_UINT32 uROP3;

/* windows ROP code for display */

L_UCHAR L_FAR * pBuffer;

/* pointer to the source buffer */

L_INT nRow;

/* first row to paint */

L_INT nCount;

/* number of rows to paint */

Paints image data into a device context from a buffer. This function works the same as L_PaintDCBuffer, except that only the bitmap region is painted.

Parameter

Description

hDC

Handle to a device context, such as a screen, to use as the display surface. The mapping mode of the device context must be MM_TEXT.

pBitmap

Pointer to the bitmap handle referencing the bitmap that has the region 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.

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.

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.

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.

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.

pBuffer

Pointer to the buffer that contains the image data to paint.

nRow

The first row to paint. The painted portion of any row may be limited by the RECT parameters.

nCount

The number of rows to paint. The painted portion of any row may be limited by the RECT parameters.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The bitmap must be allocated before you can create a region for it. Therefore, if you use this function in a paint-while-load routine, you must use your callback function to create the region after the bitmap is allocated.

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 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_FrameBitmapRgn, L_PaintRgnDC, L_PaintRgnDCEffect, L_WindowLevel, L_RectToBitmap, L_RectFromBitmap

Topics:

Raster Image Functions: Displaying Images

 

Raster Image Functions: Palettes

 

Defining and Using a Bitmap Region

 

Handling Palette Changes

Example

For complete sample code, refer to the FEATURE3 example.

/* This FILEREADCALLBACK function creates a region and paints the 
 region as it loads the file. */
/**************** Global declarations **************************************/
BITMAPHANDLE LeadBitmap;   /* Bitmap handle */
HPALETTE hpalPaint;        /* Paint palette handle */
HINSTANCE hInst;   /* Current instance of the application, set by the InitInstance function */
RECT rLeadDest;            /* Destination rectangle for painting */     
RECT rLeadSource;          /* Source rectangle for painting */
FILEINFO FileInfo;         /* LEAD File Information structure. */
/* Structure used for the callback function's user data */
typedef struct tagIMAGECBPARM
{
   HWND hwnd;     /* Current window */
   HDC hdc;       /* Device context for the current window */
} IMAGECBPARM;
/*******************************************************************************/
L_INT L_EXPORT EXT_CALLBACK LoadImageCB(pFILEINFO pFileInfo, pBITMAPHANDLE pBitmap, 
         L_UCHAR L_FAR *pBuffer,
         L_UINT uFlags, L_INT nRow, L_INT nLines, IMAGECBPARM L_FAR* pUserData )
{
   RGNXFORM XForm; /* Structure for transforming display coordinates */
   RECT rRgnRect; /* Rectangle that defines the region */
   RECT rClientSize;
   /* If this is the first call (nRow = 0), select and realize the palette;
   and create the region to be painted */
   if((uFlags & FILEREAD_FIRSTPASS) && (uFlags & FILEREAD_FIRSTROW))
   {
         /* Set the source rectangle to use the whole bitmap */
         SetRect(&rLeadSource, 0, 0, pFileInfo->Width, pFileInfo->Height);
         SendMessage (pUserData->hwnd, WM_QUERYNEWPALETTE, 0, 0L);
         SelectPalette( pUserData->hdc, hpalPaint, TRUE );
         RealizePalette(pUserData->hdc);
         /* Set RGNXFORM fields,  */
         XForm.uViewPerspective = TOP_LEFT;
         XForm.nXScalarNum = pFileInfo->Width;
         XForm.nXScalarDen = rLeadDest.right - rLeadDest.left;
         XForm.nYScalarNum = pFileInfo->Height;
         XForm.nYScalarDen = rLeadDest.bottom - rLeadDest.top;
         XForm.nXOffset = 0;
         XForm.nYOffset = 0;
         /* Specify a rectangle to define the region */
         SetRect(&rRgnRect, rClientSize.right/8, rClientSize.bottom/8, 
            rClientSize.right/2, rClientSize.bottom/2);
         /* Create an elliptical region */
         L_SetBitmapRgnEllipse(&LeadBitmap, &XForm, &rRgnRect, L_RGN_SET);
   }
   /* Paint the buffer to the specified device context */
   L_PaintRgnDCBuffer( 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,        /* Normal ROP code for painting */
                    pBuffer,        /* Input buffer - from function parameter */
                    nRow,           /* First row in buffer - from function parameter */
                    nLines );       /* Number of lines in the buffer - from function parameter */
return( SUCCESS );
}