Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting color depth-16 color, 256 color, or 32 bit color
#21
(08-17-2024, 02:17 AM)Pete Wrote: Terry,

Since you are error trapping, isn't this line redundant?

IF i > -2 THEN EXIT FUNCTION

Pete
Yep, sure is. But in the other thread RhoSigma made a good point about how using ON ERROR the way I am will not preserve any previous ON ERROR label that may have existed. It looks like I'll need to remove the .BI file and ON ERROR statement completely any way.

As I said in the other thread, what is really needed is a way to verify that image handles are valid.

_VALIDIMAGE(Handle&)

or something similar. Image handles can't exist above -2 but there is no way to check if a number within the valid handle range actually contains an image. This would be useful for another reason too. When you free an image (_FREEIMAGE) any associated variable that contains the handle value still retains that value. I've made it a habit after freeing an image to also set any associated variable to -1.

_FREEIMAGE(MySprite&)
MySprite& = -1

This way checks for -2 or less will catch this as an invalid image handle since it was previously removed.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: Detecting color depth-16 color, 256 color, or 32 bit color - by TerryRitchie - 08-17-2024, 03:08 AM



Users browsing this thread: 1 Guest(s)