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

# TRasterImage.Assign

Assign - copies details from Source according to data type.

## Declaration

Source position: graphics.pp line 1306

`public procedure TRasterImage.Assign(`
`Source: TPersistent`
`); override;`

## Arguments

`Source` |  | Persistent object with values copied in the method.

## Description

Assign is a procedure used to copy values from the specified TPersistent object into the current class instance. Assign is overridden to handle using a TRasterImage or TFPCustomImage instance in the Source parameter.

No actions are performed in the method when Source is the same class instance as the current class instance (Self).

When Source is a TRasterImage instance, the following actions are performed:

- Clears an allocated mask handle by calling UpdateHandles.
- Sets TransparentMode, TransparentColor, and Masked to the values in Source.
- Frees an existing Canvas context when shared images are not the same.
- Makes a copy of the shared image in Source when they are of the same image class.
- Creates a new shared image and copies its raw image data when they are NOT of the same image class.
- Copies an allocated mask handle from Source.
- Calls Changed to update Modified and signal the OnChange event handler (when assigned).

When Source is a TFPCustomImage instance, the following actions are performed:

- Copies the raw image data from Source using its bitmap and mask handles.
- Calls UpdateHandles to reflect the new handles in the current class instance.
- Calls Changed to update Modified and signal the OnChange event handler (when assigned).

For other TPersistent descendants, the inherited method is called using Source as an argument.

## See also

TGraphic.Assign |  | Implements object persistence for the TGraphic type.