In C or C++ is there any way to read the color palette RGB values directly? Especially interesting is the extended color space used by xterm (and others) to d
[Edit 1] sorry this not leads to solution but for others i added DAC palette IO access
look the old legacy EGA/VGA references ...
for direct access try this:
BYTE r,g,b,c=5; // R,G,B values are 6 bit only !!!
out 0x3C8,c; // set color index to work with <0,255>
in r,0x3C9; // read color pallete for color c
in g,0x3C9; // not sure if it should be r,g,b
in b,0x3C9; // or b,g,r ... i did not use it for too many years
out 0x3C8,c; // set color index to work with <0,255>
out 0x3C9,r; // write color pallete for color c
out 0x3C9,g;
out 0x3C9,b;
C/C++ do not have in,out operations so use this:
BYTE i,o; // this must be local !!!
WORD port; // this must be local !!!
asm {
mov dx,port // in i,port
in al,dx
mov o,al
mov dx,port // out port,o
mov al,o
out dx,al
}