?
Solved

How save Screen to Bitmap image?

Posted on 2000-03-23
4
Medium Priority
?
380 Views
Last Modified: 2010-05-18
How save Screen to Bitmap image in C++?
Please can anyone send me example code?
0
Comment
Question by:Viesturs
[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
  • 2
4 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2649340
Standard C++ provides no mechanism for this.  Standard C++ doesn't even assume there is a screen, much less contain any features for dealing with bitmaps.

In order to do this you will have t make use of Operating System-specific code.  That raises the question--What operating system do you need this for?

In windows you can use

HDC ScreenDC = CreateDC("DISPLAY",NULL,NULL,NULL);
HDC MemDC = CreateCompatibleDC(ScreenDC);
HBITMAP BitMap = CreateCompatibleBitmap(ScreenDC,GetSystemMetrics(SM_CXSCREEN),GetsystemMetrics(SM_CYSCREEN))
HBITMAP OldBmp = SelectObject(MemDC,BitMap);

BitBlt(MemDC,0,0,,GetSystemMetrics(SM_CXSCREEN),GetsystemMetrics(SM_CYSCREEN),ScreenDC,0,0,SRCCOPY);

SelectObject(MemDC,OldBmp);
DeleteDC(ScreenDC);
DeleteDC(MemDC);

The code creates a DC for the screen and a compatible one for a memory bitmap.  Then it creates a memory bitmap the same size as the screen.  It selects the memory bitmap into the memory DC.  Then it copies the screen's bitmap to the memory bitmap with BitBlt().   Then it cleans up by restoring the memory DC's original bitmap (important step!).  and deletes the two DCs.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2649359
 WINCAP Captures Screens Using DIB API
http://support.microsoft.com/support/kb/articles/q97/1/93.asp

Create dib and save to disk.
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 150 total points
ID: 2657118
I repete my reply:
  WINCAP Captures Screens Using DIB API
http://support.microsoft.com/support/kb/articles/q97/1/93.asp 
Create dib and save to disk.
Alex


0
 
LVL 1

Author Comment

by:Viesturs
ID: 2660114
Spasibo. Primer skachal, tolko ne uspel posmotrets. :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

764 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