0% found this document useful (0 votes)
12 views8 pages

1740355857-Getimage and Putimage Functions

The document provides an overview of the getimage() and putimage() functions used in computer graphics to manipulate images in memory. The getimage() function captures a specified rectangular area from the screen and stores it in memory, while putimage() displays the stored image back on the screen using various operators to control how the image is rendered. It includes syntax, descriptions, and sample code for both functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

1740355857-Getimage and Putimage Functions

The document provides an overview of the getimage() and putimage() functions used in computer graphics to manipulate images in memory. The getimage() function captures a specified rectangular area from the screen and stores it in memory, while putimage() displays the stored image back on the screen using various operators to control how the image is rendered. It includes syntax, descriptions, and sample code for both functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Department of MSc Software Systems and Computer Science(PG)

Subject Name : Computer Graphics


Subject Code : 43B
Class : II MSc SS
Semester : IV
Prepared by : Dr.V.V.Gomathi
Assistant Professor
Department of MSc Software Systems and
Computer Science(PG)
KG College of Arts and Science
getimage() and putimage()
functions
getimage function saves a bit image of specified region into memory,
region can be any rectangle.
Declaration:- void getimage(int left, int top, int right, int bottom, void
*bitmap);
getimage copies an image from screen to memory. Left, top, right,
and bottom define the area of the screen from which the rectangle is
to be copied, bitmap points to the area in memory where the bit
image is stored.
getimage is the function used to used to copy a portion (rectangle) into
the memory.

It accepts 5 parameters - left, top, right, bottom and image pointer (void
far*).

Sufficient memory needs to allocated. imagesize is the function used to


calculate the image size of the given rectangle.

Once the image is captured using getimage, we can use putimage to plot
the image.

In putimage function, we need to specify the point (x,y) where needs to


be drawn and pointer of the image buffer and operator - type of copy.
The operator can be COPY_PUT if you want to have exact copy.

Alternatively you can specify XOR_PUT, OR_PUT, AND_PUT or NOT_PUT.


Look at the following lines in the sample code.
void far *image = 0;
sz = imagesize(left, top - 35, right + 35, bottom);
image = farmalloc(sz);
// getimage
getimage(left, top - 35, right + 35, bottom, image);
putimage(left, bottom + 10, image, NOT_PUT);
putimage(left, top - 170, image, COPY_PUT);
getimage()

Syntax
#include <graphics.h>
void getimage(int left, int top, int right, int bottom, void *bitmap);

Description
getimage copies an image from the screen to memory.
left, top, right, and bottom define the screen area to which the
rectangle is copied. bitmap points to the area in memory where the
bit image is stored. The first two words of this area are used for the
width and height of the rectangle; the remainder holds the image
itself.
Putimage()
Syntax
#include <graphics.h>
void putimage(int left, int top, void *bitmap, int op);
Description
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.
Name Value Description
COPY_PUT 0 Copy
XOR_PUT 1 Exclusive or
OR_PUT 2 Inclusive or
AND_PUT 3 And
NOT_PUT 4 Copy the inverse of the source
In other words, COPY_PUT copies the source bitmap image onto the
screen, XOR_PUT XORs the source image with the image already
onscreen, OR_PUT ORs the source image with that onscreen, and so
on.

You might also like