Borland C++ reference

putimage

raw OCR

Outputs a bit image to screen.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
void  far putimage(int    left, int top, void far *bitmap, int op);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

putimage puts the bit image previously saved with getimage back onto the screen, with the upper left corner of the image placed at {left,top), bitmap points to the area in memory where the source image is stored.

The op parameter to putimage specifies a combination operator that controls how the color for each destination pixel onscreen is computed, based on the pixel already onscreen and the corresponding source pixel in memory. The enumeration putimage_ops, as defined in graphics.h, gives names to these operators.

NameValueDescription
COPY PUT0Copy
XOR PUT1Exclusive or
OR PUT2Inclusive or
AND PUT3And
NOT PUT4Copy the inverse of the source
In other words, COPY_PUTcopies the source bitmap image onto the
screen, XORPUTXORs the source image with that already onscreen,
ORPUTORs the source image with that onscreen, and so on.

Return value

None.

See also

Example

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

tdefine ARROW_SIZE 10

void draw_arrow (int x, int y);

int mainO
{
   /* request autodetection  */
    int gdriver = DETECT, gmode, errorcode;
   void  *arrow;
    int X, y, maxx;
   unsigned  int size;
    /* initialize graphics and local variables */
   initgraph(&gdriver,  &gmode, "");

   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 = getmaxx ();
   X = 0;
   y = getmaxy () / 2;
   draw_arrow(x, y) ;

   /* calculate the  size of the image and allocate space for it */
   size = imagesize(x, y-ARROW_SIZE,  x+(4*ARR0W_SIZE), y+ARROW_SIZE)
   arrow = malloc(size) ;

   /* grab the  image */
   getimage(x, y-ARROW_SIZE,  x+(4*ARR0W_SIZE), y+ARROW_SIZE, arrow);

   /* repeat until a key  is pressed */
   while  (IkbhitO)  {
      /* erase old image  */
      putimage(x, y-ARROW_SIZE,  arrow, XOR_PUT);
      X += ARROW_SIZE;
      if  (x >= maxx)
         X = 0;
      /* plot new image  */
      putimage(x, y-ARROW_SIZE,  arrow, XOR_PUT);
   }
   free (arrow);
   closegraphO  ;
   return 0;
}
void draw_arrow(int x, int y)  {
   moveto(x, y);
   linerel(4*ARR0W_SIZE, 0);
   linerel(-2*ARR0W_SIZE, -1*ARR0W_SIZE) ;
   linereKO,  2*ARR0W_SrZE) ;
   linerel (2*ARR0W_SIZE, -1*ARR0W_SIZE);

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.