Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trouble filling in a closed vector shape
#31
That makes sense - I asked how we might gracefully determine if an image handle is associated with an image before doing _FreeImage and @SMcNeill had an answer that works for me... 

(11-11-2025, 12:53 AM)SMcNeill Wrote:
Code: (Select All)

SUB FreeImage (handle AS LONG)
   IF handle < -1 THEN 
     _FREEIMAGE handle
    handle = 0
   END IF
END SUB
Just write your own freeimage routine and have it *always* set to handle back to 0 when it's freed the handle.
If a handle isn't loaded at all, then it's going to be 0.
If a handle is > 0 then it's going to be a screen handle and not needing to be freed.
Only LOAD when handles are 0 or -1, and only FREE when the handle is < -1 and then set the handle back to 0.
It's about the easiest way to deal with the issue that I know of.
and @RhoSigma had some good suggestions too: 

(11-11-2025, 10:33 AM)RhoSigma Wrote: IMO it should be handle = -1 instead of 0, as -1 is the official invalid image handle value, while 0 could be a screen page in legacy screens and get missinterpreted as the current destination page.
Best is probably to use the provided compiler constants, hence handle = _INVALID_IMAGE.
One should be able to safely call that custom FreeImage routine at the end of a program or routine without having to worry about an error if the image has already been freed. 

Good to know about that maptriangle for filled triangles!
Reply
#32
Still I don't believe it necesary to free images at the end of a program what do the developers who know under-the-hood stuff say? @SMcNeill the amazing, @DSMan195276 the Super Moderator @a740g the serious serious

Inquiring minds need to know! I cant imagine any program would leave stuff in RAM after closing thats like not wiping your butt after... never mind. Smile
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  simple 3d starfield & wireframe or vector graphics revisited madscijr 5 263 01-31-2026, 09:41 PM
Last Post: Pete
  trouble building ansiprint by a740g hsiangch_ong 2 578 01-09-2025, 12:57 AM
Last Post: hsiangch_ong
  Having trouble Windows command line SORT via SHELL GTC 19 4,367 08-26-2023, 04:19 AM
Last Post: GTC
  How do I paint a shape? PhilOfPerth 21 3,921 06-28-2023, 10:09 PM
Last Post: TempodiBasic
Photo Ellipse trouble james2464 14 2,998 08-25-2022, 10:52 PM
Last Post: james2464

Forum Jump:


Users browsing this thread: 1 Guest(s)