Android Problem with a Bitmap Container


I am having a strange problem with bitmaps I add to a bitmap container but only on the Android platform. iOS is fine.

An example project can be found here:

To see the problem run the application and you will see that the images, which are just the squares on a scrabble board, are fine. But if you switch to another app and back again the images disappear.

If add the images at design time it all works fine.

Thanks in advance,

Ken Randall

It's unclear why exactly the images disappear. It seems to be an invalid handle issue, but we are currently unable to point out exactly where the issue occurs. A possible solution would be to draw the image inside a rectangle instead of manipulating the fill of the rectangle.

I don't want to draw the image as I need to be able to zoom and this is an easier way. I have however tried using TImage instead of TRectangle and the result is the same. What I don't understand is that it is fine if I add the images yo the container at design time.


We have further investigated this here and found out the following QC report:

A possible workaround is to use a memory stream to assign the bitmap to the fill. When assigning, the data is not copied, but referenced instead, which is the cause for the disappearing bitmaps after closing/reopening the application.

      ms := TMemoryStream.Create;
        case Multi[Rw,Cl] of


We are currently investigating a workaround on component level.

Thanks, very interesting and does indeed work. What also works, so that I don't have to change any other code in the real app, is when adding the bitmap to the container to first save the bitmap to a memory stream and then load the containers bitmap property from the stream.

Great support as usual!

Thank you for your feedback.

Re: We are currently investigating a workaround on component level.

Have you got any further withthis?


We haven't found a solid workaround on component level. 
The workaround above can be used until the issue is fixed by Embarcadero.

Ok, thanks.