Quick FMX tip – TBitmap.CopyFromBitmap is not synonymous with TBitmap.Assign

Quick FireMonkey tip – if you are calling the CopyFromBitmap method of TBitmap and wondering why it isn’t working (cf. the first issue reported here), it’s probably because you are attempting to write to an empty bitmap. In other words, like the CopyRect method in the VCL, CopyFromBitmap does not resize the destination bitmap, so the latter needs to be big enough beforehand if you want all the source pixels to be copied over. Nonetheless, if you want to resize the destination bitmap as well, just call Assign rather than CopyFromBitmap:

DestImage.Bitmap.Assign(SourceBitmap);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s