Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_FREEIMAGE Behavior
#4
(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? Smile
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
I'm creating image manipulation routines that pass an image in (InImg) and send an image out (OutImg). The problem arose with OutImg, for example:

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.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
_FREEIMAGE Behavior - by TerryRitchie - 12-17-2023, 08:21 PM
RE: _FREEIMAGE Behavior - by MasterGy - 12-17-2023, 08:59 PM
RE: _FREEIMAGE Behavior - by TerryRitchie - 12-17-2023, 09:13 PM
RE: _FREEIMAGE Behavior - by SMcNeill - 12-17-2023, 09:05 PM
RE: _FREEIMAGE Behavior - by TerryRitchie - 12-17-2023, 09:15 PM
RE: _FREEIMAGE Behavior - by SMcNeill - 12-17-2023, 10:03 PM
RE: _FREEIMAGE Behavior - by SMcNeill - 12-17-2023, 10:05 PM
RE: _FREEIMAGE Behavior - by TerryRitchie - 12-17-2023, 10:32 PM



Users browsing this thread: 1 Guest(s)