Solved

How save Screen to Bitmap image?

Posted on 2000-03-23
4
368 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
  • 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 50 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
SetCurrentDirectory path limit 7 143
C++ assignment question 7 266
convert char array to number in c 5 89
Adding items to a C# list incrementally 5 58
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

679 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