• C

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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Amansol;

What's your O/S?

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AymansolAuthor Commented:
I'm using MS-Dos 6.22 matt thanks for your care
MSSPs - Are you paying too much?

WEBINAR: Managed security service providers often deploy & manage products from a variety of solution vendors. But is this really the best approach when it comes to saving time AND money? Join us on Aug. 15th to learn how you can improve your total cost of ownership 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.