Can I delete an image after adding it to the ImageGadget?

Just starting out? Need help? Post your questions and find answers here.
Lebostein
Addict
Addict
Posts: 826
Joined: Fri Jun 11, 2004 7:07 am

Can I delete an image after adding it to the ImageGadget?

Post by Lebostein »

Or does the image have to be available with its ImageID as long as I want to display it in the ImageGadget?
User avatar
Jacobus
Enthusiast
Enthusiast
Posts: 139
Joined: Wed Nov 16, 2005 7:51 pm
Location: France
Contact:

Re: Can I delete an image after adding it to the ImageGadget?

Post by Jacobus »

Hi Lebostein,
You can find some useful functions for image management in ImageGadget() and more here:
viewtopic.php?t=85730
This should help you
PureBasicien tu es, PureBasicien tu resteras.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Can I delete an image after adding it to the ImageGadget?

Post by Caronte3D »

Lebostein wrote: Thu Jun 05, 2025 6:51 am Or does the image have to be available with its ImageID as long as I want to display it in the ImageGadget?
If you don't want to use the image later (beside of the ImageGadget), I think you can free the image without problem, but it's not needed.
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Can I delete an image after adding it to the ImageGadget?

Post by breeze4me »

It seems that an image should not be removed on Windows.
Instead of using RedrawWindow, you can move the window to an offscreen area and then move it back and see that both images have been erased.

Code: Select all

If OpenWindow(0, 0, 0, 245, 105, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/Map.bmp")
    ImageGadget(0,  10, 10, 100, 83, ImageID(0))                     ; imagegadget standard
    ImageGadget(1, 130, 10, 100, 83, ImageID(0), #PB_Image_Border)   ; imagegadget with border
    
    FreeImage(0)
    
    RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASENOW | #RDW_UPDATENOW | #RDW_INVALIDATE | #RDW_ALLCHILDREN | #RDW_ERASE)
  EndIf
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
User avatar
minimy
Enthusiast
Enthusiast
Posts: 551
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Can I delete an image after adding it to the ImageGadget?

Post by minimy »

Hello, i think the solution is canvasgadget. Can draw the image in a canvas. Delete the image no give error.
If translation=Error: reply="Sorry, Im Spanish": Endif
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Can I delete an image after adding it to the ImageGadget?

Post by Fred »

If it works on Linux and MacOS, there is an inconsistency here and the image should be duplicated on Windows as well.
Post Reply