QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _PALETTECOLOR function is used to return the 32-bit attribute color setting of an image or screen page handle’s palette.

Syntax

color32Value& = _PALETTECOLOR(attributeNumber%, imgHandle&)

Description

Example(s)

How _PALETTECOLOR works on 32-bit RGB compared to a 4-BPP (SCREEN 12) QBasic procedure.


SCREEN 12                         'can use any QBasic legacy screen mode
DIM RGB(0 TO 47) AS INTEGER       'color intensity array
FOR c& = 0 TO 15
  'OUT &H3C7, c&                  'set color attribute to read
  value32& = _PALETTECOLOR(c&, 0) 'sets color value to read of an image page handle.
  'red% = INP(&H3C9)
  red% = _RED32(value32&)
  'green% = INP(&H3C9)
  green% = _GREEN32(value32&)
  'blue% = INP(&H3C9)
  blue% = _BLUE32(value32&)
  RGB(c& * 3) = red%: RGB((c& * 3) + 1) = green%: RGB((c& * 3) + 2) = blue%
NEXT
FOR i = 0 TO 47 STEP 3
  RGBval$ = LTRIM$(STR$(RGB(i))) + "," + STR$(RGB(i + 1)) + "," + STR$(RGB(i + 2)) + ")"
  PRINT "Color"; i / 3, "_RGB(" + RGBval$;
  PRINT
NEXT
END

Explanation: To save a bitmap or other image you need the RGB color settings or the colors will look all wrong. You can store that information into a larger image array and GET the image AFTER the color settings. Just GET the image starting at Array(48).

See Also