The following example calls
GdipDrawCachedBitmap to draw the image stored in a
CachedBitmap.
C++
VOID Example_CachedBitmap(HDC hdc)
{
Graphics graphics(hdc);
Bitmap bitmap(L"Grapes.jpg");
CachedBitmap cachedBitmap(&bitmap, &graphics);
graphics.DrawCachedBitmap(&cachedBitmap, 10, 10);
}
PowerBASIC
SUB GDIP_DrawCachedBitmap (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pBitmap AS DWORD
LOCAL pCachedBitmap AS DWORD
LOCAL strFileName AS STRING
hStatus = GdipCreateFromHDC(hdc, pGraphics)
' // Create a Bitmap from a JPEG file.
strFileName = UCODE$("climber.jpg")
hStatus = GdipCreateBitmapFromFile(STRPTR(strFileName), pBitmap)
' // Use the Bitmap to create a CachedBitmap.
hStatus = GdipCreateCachedBitmap(pBitmap, pGraphics, pCachedBitmap)
' // Draw the cached bitmap.
hStatus = GdipDrawCachedBitmap(pGraphics, pCachedBitmap, 20, 10)
' // Cleanup
IF pCachedBitmap THEN GdipDeleteCachedBitmap(pCachedBitmap)
IF pBitmap THEN GdipDisposeImage(pBitmap)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipDrawCachedBitmap.png)