Graphics::DrawCachedBitmap method (gdiplusgraphics.h)

The Graphics::DrawCachedBitmap method draws the image stored in a CachedBitmap object.

Syntax

Status DrawCachedBitmap(
  [in] CachedBitmap *cb,
  [in] INT          x,
  [in] INT          y
);

Parameters

[in] cb

Type: CachedBitmap*

Pointer to a CachedBitmap object that contains the image to be drawn.

[in] x

Type: INT

Integer that specifies the x-coordinate of the upper-left corner of the image.

[in] y

Type: INT

Integer that specifies the y-coordinate of the upper-left corner of the image.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

A CachedBitmap object stores an image in a format that is optimized for a particular display screen. You cannot draw a cached bitmap to a printer or to a metafile.

Cached bitmaps will not work with any transformations other than translation.

When you construct a CachedBitmap object, you must pass the address of a Graphics object to the constructor. If the screen associated with that Graphics object has its bit depth changed after the cached bitmap is constructed, then the Graphics::DrawCachedBitmap method will fail, and you should reconstruct the cached bitmap. Alternatively, you can hook the display change notification message and reconstruct the cached bitmap at that time.

Examples

The following example calls Graphics::DrawCachedBitmap to draw the image stored in a CachedBitmap object.

VOID Example_DrawCachedBitmap(HDC hdc)
{
   Graphics graphics(hdc);

   // Create Bitmap object.
   Bitmap bitmap(L"Climber.jpg");

   // Use the Bitmap object to create a CachedBitmap object.
   CachedBitmap cachedBitmap(&bitmap, &graphics);

   // Draw the cached bitmap.
   graphics.DrawCachedBitmap(&cachedBitmap, 20, 10);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusgraphics.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Bitmap

Drawing, Positioning, and Cloning Images

Graphics

Using a Cached Bitmap to Improve Performance