#include "l_bitmap.h"
L_LTDIS_API L_INT L_DoubleBufferEnd(hDoubleBufferHandle, hDC)
Displays the double buffered paint operations.
Handle that identifies the double buffering process.
Handle to the original target device context.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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
Win32, x64.
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 --
#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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document