?
Solved

what is the most appropriate program for getimage

Posted on 2003-03-17
5
Medium Priority
?
316 Views
Last Modified: 2010-05-18
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
Comment
Question by:piyu37wala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Accepted Solution

by:
gj62 earned 380 total points
ID: 8154432
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
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 8154526
"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
 
LVL 5

Assisted Solution

by:Kocil
Kocil earned 380 total points
ID: 8164101
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
 
LVL 20

Expert Comment

by:jmcg
ID: 10144490
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question