[Lazarus] A bitmap strange issue

Giuliano Colla giuliano.colla at fastwebnet.it
Sun Apr 22 17:36:19 CEST 2018

Il 22/04/2018 13:22, Michael Van Canneyt via Lazarus ha scritto:

> This is how all properties that are  TPersistent descendents work, so 
> this
> behaviour should not come as a surprise. 

I wouldn't say so.

E.g. TCanvas is a TPersistent descendent, but the Canvas property of a 
TCustomControl is declared like that:
>      property Canvas: TCanvas read FCanvas write FCanvas;
This means that after a

SomeControl.Canvas := MyCanvas;


MyCanvas := SomeControl.Canvas;

SomeControl.Canvas and MyCanvas will be the same object. Only a pointer 
is copied.

On the contrary, the property Bitmap of a TPicture is declare like that:

>      property Bitmap: TBitmap read GetBitmap write SetBitmap;

where GetBitmap actually returns the TPicture.Bitmap Object, while 
SetBitmap creates a different Bitmap Object, and assigns it the content 
of the supplied bitmap (see TPicture.SetGraphic, called by 

This means that after a

MyBitmap := SomePicture.Bitmap;

MyBitmap and SomePicture.Bitmap will represent the same Object, while 
after a

SomePicture.Bitmap := MyBitmap;

MyBitmap and SomePicture.Bitmap will represent different Objects.

This is IMHO a TPicture specific inconsistency.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180422/3ce63141/attachment.html>

More information about the Lazarus mailing list