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.
AymansolAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

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

COLORREF 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:

0x00bbggrr  

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.
0
 
MatthewLCommented:
Hi Amansol;

What's your O/S?

Matt
0
 
AymansolAuthor Commented:
I'm using MS-Dos 6.22 matt thanks for your care
0
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!

 
KangaRooCommented:
Do you use any libraries or are you going straight to the video card.
0
 
viktornetCommented:
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)
{
  SetMode(0x0013);
  for (int i = 0; i < 1000; i++)
    PutPixel(rand()%320, rand()%200, rand()%256);
  getch();
  SetMode(0x0003);
  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....

..-=ViKtOr=-..
0
 
amer_fCommented:
10 pts. is not enougth
0
All Courses

From novice to tech pro — start learning today.