Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

what is the most appropriate program for getimage

I want to getimage whole of the 640*480 screen in borland turbo C++ version 3.0,but unable to do it.
please give me the program which runs in all conditions.
It is not so easy -mind u.
piyu37wala
0
piyu37wala
Asked:
piyu37wala
2 Solutions
 
gj62Commented:
Well, what is not working?

void *image;
image = malloc(imagesize(0, 0, getmaxx(), getmaxy());
getimage(0, 0, getmaxx(), getmaxy(), image);

This *should* get the entire screen, regardless of resolution
0
 
Kent OlsenData Warehouse Architect / DBACommented:
"the program which runs in all conditions" doesn't exist.

However, gj62's solution should work for any Windows program, regardless of screen resolution.

Unless you're trying to capture a DOS window via gettext() he's given you the definitive word.

:)
0
 
KocilCommented:
Let see, for 256 color (1 byte per pixel) we need memory:
640x480x1 byte = 3307200 bytes.

So this code
   image = malloc(imagesize(0, 0, getmaxx(), getmaxy());
won't work because malloc on DOS can't give you memory more than 64K chunks.

If you want to directly save it to file, the bestway is to save it part by part.

int x_size, y_size, y;
long img_size;
void *buffer;
FILE* f;

x_size = getmaxx();
y_size = 80;  
img_size = imagesize(0,0,x_size,y_size)
/* img_size must less than 64K */

buffer=malloc(img_size);
f = fopen("screen.bin", "w");

for (y=0; y<getmaxy(); y+=y_size) {
  getimage(0, y, x_size, y+y_size, buffer);
  write(f, img_size, 1, buffer);
}
fclose(f);
free(image);

0
 
jmcgOwnerCommented:
Nothing has happened on this question in more than 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between gj62 and Kocil.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now