Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting color depth-16 color, 256 color, or 32 bit color
#6
(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.

Try this:
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
    Screen a(i)
    Select Case _PixelSize
        Case 4: Print "32-bit color"
        Case 1:
            cu = 0
            For j = 0 To 255
                If _PaletteColor(j) <> &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'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.
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-16-2024, 04:45 PM



Users browsing this thread: 6 Guest(s)