L_DoubleBufferEnd - Raster Imaging C API Help

L_DoubleBufferEnd

#include "l_bitmap.h"

L_LTDIS_API L_INT L_DoubleBufferEnd(hDoubleBufferHandle, hDC)

L_HANDLE hDoubleBufferHandle;

double buffering handle

L_HDC hDC;

handle to the target device context

Displays the double buffered paint operations.

Parameter

Description

hDoubleBufferHandle

Handle that identifies the double buffering process.

hDC

Handle to the original target device context.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Use L_DoubleBufferEnd when ready to paint all that has been double-buffered to the target hDC. All double buffered paint operations should be wrapped in L_DoubleBufferBegin and L_DoubleBufferEnd calls.

The hDC argument is the device context that you want to double buffer, which in this case should be the same as the hDC argument that was passed to L_DoubleBufferBegin.

Note that you must create a double buffer handle with L_DoubleBufferCreateHandle before calling this function.

For more information, see the topic Minimizing Flicker With Double Buffering.

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

Win32, x64.

See Also

Functions:

L_DoubleBufferEnable, L_DoubleBufferCreateHandle, L_DoubleBufferDestroyHandle, L_DoubleBufferBegin

Topics:

Raster Image Functions: Displaying Images

 

Minimizing Flicker With Double Buffering

Example

To see how double buffering can be used in an application, see the source code for the API annotation demo. This sample illustrates double buffering by bouncing a ball around a window that contains an image For simplicity, we assume both the window the hDC are 24 bit Run the example twice --

  • once with bDoubleBuffer set to FALSE
  • once with bDoubleBuffer set to TRUE to see the difference hWnd -- window to paint image and bounce ball pszFile -- file name of image to load bDoubleBuffer - flag saying whether or not to double buffer the paints
    #define BALL_RADIUS 30 
    L_INT DoubleBufferEndExample(L_HWND        hWnd, 
                                                 L_TCHAR*    pszFile, 
                                                 L_BOOL      bDoubleBuffer) 
    { 
       HBRUSH         hBrush; 
       BITMAPHANDLE   Bitmap; 
       L_HANDLE       hDoubleBufferHandle; 
       L_INT          cx, cy; 
       HDC            hDC, hMemDC; 
       RECT           rcClient; 
       RECT           rcBitmap; 
       RECT           rcBall; 
       L_INT          dx, dy; 
       L_INT          i; 
       L_INT          nRet; 
     
       nRet = L_LoadBitmap(pszFile, &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, NULL); 
       if (nRet != SUCCESS) 
       { 
          MessageBox(hWnd, TEXT("Failed to load image"), TEXT("Error"), MB_OK); 
          return nRet; 
       } 
     
       hBrush = CreateSolidBrush( RGB(100,100,100)); 
       nRet = L_DoubleBufferCreateHandle(&hDoubleBufferHandle); 
       if(nRet != SUCCESS) 
          return nRet; 
     
       nRet = L_DoubleBufferEnable(hDoubleBufferHandle, bDoubleBuffer); 
       if(nRet != SUCCESS) 
          return nRet; 
        
       GetClientRect(hWnd, &rcClient); 
       cx = rcClient.right  - rcClient.left; 
       cy = rcClient.bottom - rcClient.top; 
       hDC = GetDC(hWnd); 
     
       rcBitmap.left = 0; 
       rcBitmap.top = 0; 
       rcBitmap.right = BITMAPWIDTH(&Bitmap); 
       rcBitmap.bottom = BITMAPWIDTH(&Bitmap); 
     
       SetRect(&rcBall, 0, 0, BALL_RADIUS, BALL_RADIUS); 
       dx = dy = 1; 
       for (i=0; i<2000; i++) 
       { 
          // Double buffer painting the image and the moving ball 
          hMemDC = L_DoubleBufferBegin(hDoubleBufferHandle, hDC, cx, cy); 
          FillRect(hMemDC, &rcClient, hBrush); 
          nRet = L_PaintDC(hMemDC, &Bitmap, NULL, NULL, &rcBitmap, NULL, SRCCOPY);  
          if(nRet != SUCCESS) 
             return nRet; 
          Ellipse(hMemDC, rcBall.left, rcBall.top, rcBall.right, rcBall.bottom); 
          nRet = L_DoubleBufferEnd(hDoubleBufferHandle, hDC); 
          if(nRet != SUCCESS) 
             return nRet; 
     
          if ((rcBall.bottom) > rcClient.bottom) 
             dy = -1; 
          if (rcBall.top < 0) 
             dy = 1; 
          if (rcBall.left < 0) 
             dx = 1; 
          if ((rcBall.right) > rcClient.right) 
             dx = -1; 
          OffsetRect(&rcBall, dx, dy); 
       } 
     
       // Cleanup 
       L_FreeBitmap(&Bitmap); 
       L_DoubleBufferDestroyHandle(hDoubleBufferHandle); 
       DeleteObject(hBrush); 
       return SUCCESS; 
    } 
Help Version 20.0.2018.7.30
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help