Ideally you would not use "FreeImage" unless you were completely finished with the image and were not intending to draw it again during the program runtime (or significant portion thereof) in order to reclaim the memory that image used.
The 'removal of an image from the screen' would typically not be something necessary since conventional practice involves drawing the REQUIRED images to a buffer each 'frame'.
For example:
Graphics 800,600
;Create an image for the example
Local RedImage=CreateImage(400,600)
;Make the image red
SetBuffer ImageBuffer(RedImage)
ClsColor 255,0,0
Cls
;Create another image for the example
Local BlueImage=CreateImage(400,600)
;Make this image blue
SetBuffer ImageBuffer(BlueImage)
ClsColor 0,0,255
Cls
; Reset the cls (clear screen) color back to black.
ClsColor 0,0,0
;Set the drawing buffer to the back buffer. This is hidden from view currently
SetBuffer BackBuffer()
;Make this variable to store the state of which image to show.
Local TOGGLE=False
;INITIATE A MAIN LOOP - WILL EXIT IF ESCAPE IS PRESSED DOWN
While Not (KeyDown (1 ))
;Start the loop by clearing the screen ready for new drawing fo rthis frame
Cls
;Check if the spacebar has been pressed
If KeyHit(57)
;Yes it has, so let's change the TOGGLE value.
TOGGLE=Not TOGGLE
End If
;Now, depending on the value of TOGGLE, we can choose to display the RED image or the BLUE one.
;There's no need to 'hide' one from view or remove it from screen, since if we don't need to see it, we just don't draw it.
If (TOGGLE=False) Then DrawImage RedImage,0,0
If (TOGGLE=True) Then DrawImage BlueImage,400,0
;Swap the backbuffer to the front- this means that all the drawing we did to the back buffer during this 'frame' of the loop, will now be displayed on the visible screen.
Flip
Wend
|