12-17-2023, 09:13 PM
(12-17-2023, 08:59 PM)MasterGy Wrote: it's a bit like that, maybe it's a bad example, but I could compare it to this. I will give you a note on which is written what to bring from the store (index note). Once you have brought the goods from the store, the paper is irrelevant from then on. no one will cross the line. It stays. The advantage is that it remains in case you want to look at what you had to buy later. why should the note be crossed out?I understand what you are saying. However, I can't think of an example of why I would need to later reference the value of an image that has been removed from memory. The assigning of values to images is handled by QB64 under the hood so you're not guaranteed to ever use the same value again for any subsequent images.
I easily overcame this with a quick little subroutine:
Code: (Select All)
SUB RemoveImage (Image AS LONG)
IF Image < -1 THEN ' does an image exist?
_FREEIMAGE Image ' yes, remove the image from RAM
Image = 0 ' reset the associated image variable
END IF
END SUB
SUB FlipImage(Direction AS INTEGER, InImg AS LONG, OutImg AS LONG)
IF OutImg THEN _FREEIMAGE OutImg ' remove any leftover image
...
...
END SUB
Even though OutImg was freed the value remained. Later in the code when more images get created one of them will be assigned to the value that OutImg still contains. This was causing all kinds of freaky things to happen until I figured out what the heck was going on, LOL.