CGpGraphics.DrawCachedBitmapmethod
Draws the image stored in a **CachedBitmap** object.
Syntax
FUNCTION DrawCachedBitmap (BYVAL pCachedBitmap AS CGpCachedBitmap PTR, BYVAL x AS LONG, BYVAL y AS LONG) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
pCachedBitmap | Pointer to a CachedBitmap object that contains the image to be drawn. | |
x | The x-coordinate of the upper-left corner of the image. | |
y | The y-coordinate of the upper-left corner of the image. |
Return value
If the function succeeds, it returns StatusOk, which is an element of the GpStatus enumeration.
If the function fails, it returns one of the other elements of the GpStatus enumeration.
Description
Draws the image stored in a CachedBitmap object.
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 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.
Example
' ======================================================================================== ' The following example creates a CachedBitmap object based on a Bitmap object and a ' Graphics object. The code calls the DrawCachedBitmap method of that Graphics object ' to display the cached bitmap. ' ======================================================================================== SUB Example_CachedBitmap (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc
' // Get the DPI scaling ratios DIM rxRatio AS SINGLE = graphics.GetDpiX / 96 DIM ryRatio AS SINGLE = graphics.GetDpiY / 96 ' ScaleTransform can't be used with cached bitmaps, that can't be resized
' // Load the image DIM myBitmap AS CGpBitmap = "Climber.jpg"
' // Create a cached bitmap DIM cachedBitmap AS CGpCachedBitmap = CGpCachedBitmap(@myBitmap, @graphics)
' // Draw the cached bitmap graphics.DrawCachedBitmap(@cachedBitmap, 10 * rxRatio, 10 * ryRatio)
END SUB ' ========================================================================================
Reference
- Include file
CGpGraphics.inc - Defined in AfxNova/CGpGraphics.inc:1026
- Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
- Topic: CGpGraphics Class