Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting color depth-16 color, 256 color, or 32 bit color
#7
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)
DIM a(3)
a(1) = _NEWIMAGE(640, 480, 32)
a(2) = _NEWIMAGE(640, 480, 256)
a(3) = _NEWIMAGE(640, 480, 12)
FOR i = 1 TO 3
    SELECT CASE _PIXELSIZE(a(i))
        CASE 4: PRINT "32-bit color"
        CASE 1:
            cu = 0
            FOR j = 0 TO 255
                IF _PALETTECOLOR(j, a(i)) <> &HFF000000 THEN cu = cu + 1
            NEXT
            SELECT CASE cu
                CASE IS <= 16: PRINT "16 color image"
                CASE ELSE: PRINT "256 color image"
            END SELECT
    END SELECT
    SLEEP
NEXT
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply


Messages In This Thread
RE: Detecting color depth-16 color, 256 color, or 32 bit color - by TerryRitchie - 08-16-2024, 05:28 PM



Users browsing this thread: 19 Guest(s)