Hello any body know's IN turbo c How can i put a pixel with
color values 256 pair Red ,blue, green... plz give code ....
Printable View
Hello any body know's IN turbo c How can i put a pixel with
color values 256 pair Red ,blue, green... plz give code ....
to the best of my knowledge... u can't do it using conio.h
which is the graphic library w/h Turbo C uses.
To put a pixel in VGA mode w/o using BGI you will access the video memory directly.
Code:unsigned char *Screen=(unsigned char *)MK_FP(0xa000,0);
Screen[y*320+x]=paletteindex;
To change a palette entry:
To get a palette entry:Code:outp(0x03C8,index);
outp(0x03C9,red);
outp(0x03C9,green);
outp(0x03C9,blue);
This will get the current palette's respective RGB valuesCode:outp(0x03C7,index)
red=inp(0x03C9);
green=inp(0x03C9);
blue=inp(0x03C9);
You can also just send 0 to port 0x03C7 and then do 256*3 reads from port 0x03C9 to get the entire palette. Same is true with set palette. Send 0 to port 0x03C8 and then send 256*3 values to port 0x03C9.Code:struct RGB
{
unsigned char red;
unsigned char grn;
unsigned char blu;
};
RGB CurPalette[256];
for (int i=0;i<255;i++)
{
outp(0x03c7,i);
CurPalette[i].red=inp(0x03c9);
CurPalette[i].grn=inp(0x03c9);
CurPalette[i].blu=inp(0x03c9);
}
For color in non-palette modes (like VESA 16/24/32 bit modes do this:
For 565 RGB:
unsigned int color=(red<<11)+(green<<6)+blue;
For 32 bit color, or 24 bit (last byte is alpha so no worries)
unsigned long=(red<<16)+(green<<8)+blue;