• Have Any Question?
  • contact@eitworld.com

Imagesize() Function





imagesize() function is used to determine the size of memory required to store an image.

Declaration

unsigned imagesize(int left, int top, int right, int bottom);
  • imagesize() function requires forr parameters. These first forr parameters are the top-left and bottom right position of the rectangular area. imagesize() function returns the required memory area to store an image in bytes.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm,size;

char *buff;

initgraph(&gd,&gm,” “);

outtextxy(100,80,”Original image:”);

rectangle(100,200,200,275);

size=imagesize(100,200,200,275);

buf=malloc(size);

getimage(100,200,200,275,buf);

outtextxy(100,320,”Captured image:”);

putimage(100,340,buf,COPY_PUT);

getch();

closegraph();

}

It is the same that you have studied for the getimage() function. The above program will capture an image that is rectangle from memory and display it at new position. imagesize() function returns the bytes required to store the image in memory. malloc() function will allocate the memory for the image and the pointer returned by the malloc() function will be stored in the variable buff. getimage() function here will capture the image from the memory, you have already studied the getimage() function in detail and putimage() function will display the image at position (100,340) as same as the original image. You will study putimage() function in detail in the further section. The output of the above program is given below:

Output

c graphics



Real Time Web Analytics