Borland C++ reference

putpixel

raw OCR

Plots a pixel at a specified point.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
void  far putpixel(int   x, int y, int color);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

putpixel plots a point in the color defined by color at (x,y).

Return value

None.

See also

Example

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>

ttdefine PIXEL_COUNT 1000
ttdefine DELAY_TIME 100  /* in milliseconds  V
int mainO
{
   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   int i, X, y, color, maxx, maxy, maxcolor,  seed;
   /* initialize graphics and local variables  */
   initgraph(&gdriver, &gmode,  "");

   /* read result of initialization  */
   errorcode = graphresult ();
   if (errorcode != grOk) {  /* an error occurred  */
      printf("Graphics error: %s\n", grapherrormsg (errorcode));
      printf("Press any key to halt:");
      getchO ;
      exit(l);               /* terminate with  an error code */
   }

   maxx = getmaxxO  + 1;
   maxy = getmaxy() + 1;
   maxcolor = getmaxcolor () + 1;
   while (IkbhitO)
   /* seed the random number  generator */
   seed = random(32767) ;
   srand(seed) ;
   for  (i=0; i<PIXEL_COUNT; i++) {
      X = random (maxx);
      y = random (maxy);
      color = random (maxcolor);
      putpixel (x, y, color);
   }
   delay(DELAY_TIME);
   srand(seed) ;
   for  (1=0; i<PIXEL_COUNT; 1++) {
      x = random (maxx);
      y = random (maxy);
      color = random (m.axcolor);
      if  (color == getpixel(x, y))
         putpixel (x, y, 0);

/* clean up */
getchO ;
closegraph();
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.