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

# TCustomBitmap.UnshareImage

Frees the shared image in the bitmap, and creates a new one.

## Declaration

Source position: graphics.pp line 1413

`protected procedure TCustomBitmap.UnshareImage(`
`CopyContent: Boolean`
`); override;`

## Arguments

`CopyContent` |  | True copies the existing content in the shared image.

## Description

UnshareImage is an overridden method used to free the shared image in the bitmap, and create a new one. UnshareImage implements the abstract virtual method defined in the ancestor class.

UnshareImage calls GetSharedImageClass to get the class type used for the shared image, and creates a new instance of the class. It is cast to TSharedCustomBitmap, and its Reference method is called to increment the reference count for the shared image.

CopyContent indicates whether the existing image data is copied into the new shared image instance. When set to True, the content in the existing shared image is copied and stored in the new shared image instance. When set to False, only the image descriptor in the shared image is copied. This gets the metadata for the image.

UnshareImage calls FreeCanvasContext to free the device context for the Canvas used in the image.

## See also

TRasterImage.UnshareImage |  | Unshares a shared image when its handle is changed or the save stream is freed.