Title: Re: Feature Request: Quick Value Selection
Post by: FellippeHeitor on September 09, 2018, 04:50:36 pm
The third suggestion seems to fit SirCrow's need like a glove.
Title: Re: Feature Request: Quick Value Selection
Post by: SirCrow on September 09, 2018, 06:25:51 pm
I could easily have come up with numerous ways to get it done, but I wanted to see what the shortest way would be. Yes, the third method is the way I'd choose. Except, of course, that I always prefer not to use arrays if I can easily avoid it; I'm always running into Duplicate definition and other errors, clumsy as I often am.
As far as unsigned LONG integers for colors, if the regular LONG works well, why is unsigned better? Uses less memory? After all these years, I'm still a bit foggy on a lot of things.
Thanks for your input!
Title: Re: Feature Request: Quick Value Selection
Post by: FellippeHeitor on September 09, 2018, 06:45:45 pm
32bit colors require some pretty high numbers to be stored. Using a LONG or _UNSIGNED LONG will require the exact same amount of memory (4 bytes), but with a LONG you'll eventually get negative values when the color value overflows the limit of LONG data type variables.
In practice, for QB64 drawing functions, it makes no difference.
However, I remember Steve pointing out something to watch for in this regard, I just can't remember what it was.
The code above will give you two results: -1 and 4294967295, both of which represent white, full alpha (_RGB32(255, 255, 255)).
Title: Re: Feature Request: Quick Value Selection
Post by: SMcNeill on September 09, 2018, 06:54:08 pm
POINT returns unsigned values for us, so SIGNED LONGS won't always match.
SCREEN _NEWIMAGE(800,600,32) DIM White AS LONG White = _RGB32(255,255,255) PSET (1,1), White PRINT White PRINT POINT(1,1) IF POINT(1,1) = White THEN PRINT "Match" ELSE PRINT "No Match; we glitched..."
************
Change White to an Unsigned Long and then try the same code. ;)
Title: Re: Feature Request: Quick Value Selection
Post by: FellippeHeitor on September 09, 2018, 07:01:05 pm
That was that. Thanks, Steve.
Title: Re: Feature Request: Quick Value Selection
Post by: SirCrow on September 09, 2018, 09:55:18 pm
I guess I have some tildes to add to my code. Thanks.