Putting Pixel on th screen

Please, I want to know how could I put a pixel on the screen knowing its RGB not by usng palette I am using resolution 800x600.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

KangaRooConnect With a Mentor Commented:
Windows? Use SetPixel()


    HDC hdc,      // handle of device context  
    int X,      // x-coordinate of pixel
    int Y,      // y-coordinate of pixel
    COLORREF crColor       // pixel color

When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:


The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.
Hi Amansol;

What's your O/S?

AymansolAuthor Commented:
I'm using MS-Dos 6.22 matt thanks for your care
SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

Do you use any libraries or are you going straight to the video card.
Aymansol, here's how to do it under windows with a 16bit compiler...

I'm gonna show you how to work with Mode 13h which has a resolution of 320x200x256

256 is the number of colors you can have on the screen at the same time (using a palette)...


typedef unsigned char byte;

// declare a far pointer to the memory of the VGA card...
byte far* vga = (byte far *) 0xA0000000L;

// putting a pixel
void PutPixel(int x, int y, byte color)
  vga[(y<<8)+(y<<6)+x] = color;

// getting the pixel color from the screen
byte GetPixel(int x, int y)
  return vga[(y<<8)+(y<<6)+x];

// setting the mode...
void SetMode(unsigned int mode)
  asm mov ax, [mode]
  asm int 10h

//example proggy
int main(void)
  for (int i = 0; i < 1000; i++)
    PutPixel(rand()%320, rand()%200, rand()%256);
  return 0;


Mode 13h uses a palette and the resolution is 320x200 which I guess you don't want... If you want to use a higher resolution then if you have Super VGA you can use the graphics.h header file that is suppled with your compiler (hopefully).... and use BGI... which is a graphics driver that you can use.... then you can use functions such as putpixel(), getimage(), setimage() and so on to do all the stuff that you want... if you need an example proggy lemme know....

10 pts. is not enougth
All Courses

From novice to tech pro — start learning today.