[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Graphics' (#lcl)

# TRasterImage.BitmapHandleNeeded

Ensures that handles for the image and mask are valid for the raw image data.

## Declaration

Source position: graphics.pp line 1277

`protected procedure TRasterImage.BitmapHandleNeeded; virtual;`

## Description

BitmapHandleNeeded is a procedure used to ensures that handles for both the image and its mask are valid for the RawImage data. No actions are performed in the method when BitmapHandleAllocated returns True, or when RawImage data does not exist.

The MaskHandle is not created when:

- A mask handle already exists.
- The mask is created using the transparent color for the image.
- Mask values do not exist in the raw image data.

BitmapHandleNeeded calls CreateCompatibleBitmaps to get the handles for the bitmap and mask using a pointer to the raw image data, and creates a default handle if CreateCompatibleBitmaps is unsuccessful. UpdateHandles is called to assign the new handles to BitmapHandle and MaskHandle (when used).

BitmapHandleNeeded is called from the Draw method prior to performing operations using the Canvas for the class instance. It is also used when the Canvas creates a new DC (Device Context).