B4J Question Clear bitmapcreator

TomDuncan

Active Member
Licensed User
Longtime User
Hi all, how do you clear a bitmapcreator?
My initial thought was to reinitialise it but I think I am getting an error after a while.

If I'd dim one in a subroutine is it freed on exit from the routine?
Tom
 

emexes

Expert
Licensed User
If I'd dim one in a subroutine is it freed on exit from the routine?

It's not freed immediately on exit from the routine; it's more left unused and unreferenced by the side of the road and eventually the garbage collecter frees it for you, either when things are quiet or when memory supply runs low.
 
Upvote 0

TomDuncan

Active Member
Licensed User
Longtime User
So if I dim the bitmapcreator in the globals section, can I then Initialize it every time I want to use it?
 
Upvote 0

emexes

Expert
Licensed User
So if I dim the bitmapcreator in the globals section, can I then Initialize it every time I want to use it?

Lol I did wonder if maybe it was a global even though your mention of Dimming it in a Sub made it sound like a local variable.

If it is a global, then initializing it after you've finished using it should cause it to lose hold of any memory that it previously had allocated to it, and that now-unreferenced memory will eventually be gathered up by the garbage collector for reuse.

(Re-)initializing a Bitmap Creator object will probably also cause it to allocate some new memory, but I would except that to be fairly small if you stipulated new dimensions of eg 1 x 1.
 
Last edited:
Upvote 0

TomDuncan

Active Member
Licensed User
Longtime User
I had it dimmed in a sub but thought of the global dim.
Is their an easy way to just clear the bitmap so I can create it without prior image in the bitmap?
Seemed like an easy idea but old fellow cannot see how. lol
 
Upvote 0

kimstudio

Active Member
Licensed User
Longtime User
If I understand your requirement correctly: just use Bc.DrawRect() to draw any color you want for the whole bitmap.
 
Upvote 1
Top