Detecting color depth-16 color, 256 color, or 32 bit color - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: Detecting color depth-16 color, 256 color, or 32 bit color (/showthread.php?tid=2950) |
Detecting color depth-16 color, 256 color, or 32 bit color - dano - 08-16-2024 I am changing all of my libraries to be agnostic to color depth...or at least trying. I want them to automatically detect whether we are in 16 color, 256 color, or 32 bit color mode and automatically make adjustments on the fly to compensate for the colors being used, and use the proper colors. So far so good, EXCEPT that I am having an issue with accurately detecting whether we are in 16 color, 256 color, or 32 bit color. I cannot find this as a command for QB64. Is there an easy way to accurately detect this? RE: Detecting color depth-16 color, 256 color, or 32 bit color - a740g - 08-16-2024 _PIXELSIZE should be help. RE: Detecting color depth-16 color, 256 color, or 32 bit color - SMcNeill - 08-16-2024 There's an issue with trying to sort between 16-color and 256-color images. The problem is that both use 1 byte-per-pixel in memory, so you may need to compare against _PALETTECOLOR to distinguish between the two. Try this: Code: (Select All)
RE: Detecting color depth-16 color, 256 color, or 32 bit color - dano - 08-16-2024 (08-16-2024, 12:55 AM)SMcNeill Wrote: There's an issue with trying to sort between 16-color and 256-color images. The problem is that both use 1 byte-per-pixel in memory, so you may need to compare against _PALETTECOLOR to distinguish between the two.Works like a charm. Once again, thank you Steve! RE: Detecting color depth-16 color, 256 color, or 32 bit color - SMcNeill - 08-16-2024 (08-16-2024, 01:04 PM)dano Wrote:(08-16-2024, 12:55 AM)SMcNeill Wrote: There's an issue with trying to sort between 16-color and 256-color images. The problem is that both use 1 byte-per-pixel in memory, so you may need to compare against _PALETTECOLOR to distinguish between the two.Works like a charm. Once again, thank you Steve! Note that it's not fool-proof. Most things seldom are. The power of fools is astounding! Some fool out there might have a 256-color image, and 240 of the colors are all full alpha BLACK... That'd still detect as a 16-color palette. It's not *likely* to happen to you, but one should never rule out the impossible with stuff. Just keep it in the back of your mind, in case you ever get some odd glitches sometime and need to deal with them. RE: Detecting color depth-16 color, 256 color, or 32 bit color - TerryRitchie - 08-16-2024 (08-16-2024, 12:55 AM)SMcNeill Wrote: There's an issue with trying to sort between 16-color and 256-color images. The problem is that both use 1 byte-per-pixel in memory, so you may need to compare against _PALETTECOLOR to distinguish between the two.There's that thinking outside the box again. I've never bothered trying to identify 16 color versus 256 color since _PIXELSIZE can't make the distinction. _PALETTECOLOR was staring me in the face the whole time. RE: Detecting color depth-16 color, 256 color, or 32 bit color - TerryRitchie - 08-16-2024 I modified the code a bit so you don't need to use SCREEN to get the color depth of the images. Code: (Select All)
RE: Detecting color depth-16 color, 256 color, or 32 bit color - dano - 08-16-2024 Thank you. Does this also mean that there is an easy way to read the current foreground and background colors regardless of the SCREEN setting or 16/256/32bit color? RE: Detecting color depth-16 color, 256 color, or 32 bit color - SMcNeill - 08-16-2024 _DEFAULTCOLOR _BACKGROUNDCOLOR RE: Detecting color depth-16 color, 256 color, or 32 bit color - bplus - 08-16-2024 (08-16-2024, 05:52 PM)dano Wrote: Thank you. Does this also mean that there is an easy way to read the current foreground and background colors regardless of the SCREEN setting or 16/256/32bit color? _DefaultColor and _BackgroundColor |