Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to screen capture into a BMP file Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
13-Sep-02
Category
Shell API
Language
Delphi 2.x
Views
129
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert 

Screen capture into a BMP file

Answer:

This little routine grabs the whole screen, assigns it temporary to a bitmap and 
stores it into file "sample.bmp".

A potential problem:
If your system is set up to HiColor (32k colors = 15 bits per pixel), some programs 
will not be able to read the result since they are only capable to read 16 bits/ 
pixel.


1   procedure TForm1.Button1Click(Sender: TObject);
2   var
3     DeskTopDC: HDc;
4     DeskTopCanvas: TCanvas;
5     DeskTopRect: TRect;
6     Bitmap: TBitmap;
7   begin
8     DeskTopDC := GetWindowDC(GetDeskTopWindow);
9     DeskTopCanvas := TCanvas.Create;
10    DeskTopCanvas.Handle := DeskTopDC;
11    DeskTopRect := Rect(0, 0, Screen.Width, Screen.Height);
12    Bitmap := TBitmap.Create;
13    with Bitmap do
14    begin
15      Width := Screen.Width;
16      Height := Screen.Height;
17      PixelFormat := pfDevice;
18    end;
19    Bitmap.Canvas.CopyRect(DeskTopRect, DeskTopCanvas, DeskTopRect);
20    Bitmap.SaveToFile('c:\temp\sample.bmp');
21    Bitmap.Free;
22    DesktopCanvas.Free;
23    ReleaseDC(GetDeskTopWindow, DeskTopDC);
24  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC