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

Possibly Related Threads…
Thread Author Replies Views Last Post
Question using $color:32 colour names mid-program? hskakw 2 199 01-14-2026, 09:30 AM
Last Post: hskakw
Question Latest version of QB64PE or QB64 compatible with Windows XP (32-bit)? madscijr 14 1,958 09-30-2025, 08:10 AM
Last Post: hsiangch_ong
  Test to post a new Thread + question 32 or 64 bit Rudy M 2 538 09-09-2025, 04:10 PM
Last Post: Rudy M
  useful page: Value of constants for the Windows 32-bit API madscijr 4 662 08-15-2025, 06:35 PM
Last Post: SMcNeill
  _CLEARCOLOR evety color EXCEPT ...? madscijr 4 825 04-27-2025, 10:51 PM
Last Post: TempodiBasic

Forum Jump:


Users browsing this thread: 1 Guest(s)