Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Taking Screenshots for Processing in Delphi.

Posted on 2004-04-05
2
Medium Priority
?
314 Views
Last Modified: 2010-04-05
I want to be able to take screenshots of my desktop and compare then pixel by pixel or otherwise to another screenshot in memory. The purpose of this is to isolate an object from a known background and return a coordinate, preferably in real time.

Thanks alot for any help you can provide.

Tom.
0
Comment
Question by:nop-90
[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
2 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10761193
var
 screenShot : TBitmap;
 dc : HDC;
begin
 screenShot := TBitmap.create;
 with screenShot do
 begin
  pixelFormat := pf24bit;
  width := screen.wdith;
  height := screen.height;
 end;
 dc := getDC(getDeskTopWindow);
 biblt(
  screenShot.canvas.handle,
  0,0,screen.width,screen.height,
  dc,
  0,0,
  SRCCOPY);
 releaseDC(getDeskTopWindow,dc);
end;

Shane
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 375 total points
ID: 10761218
Also, here is a solution from another expert (DragonSlayer)

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20175477.html?query=screenshot&searchType=topic


Accepted Answer from DragonSlayer
Date: 08/29/2001 12:40AM PDT
 Accepted Answer  


didn't try to compile it, but I think it will work:

uses
  Windows, clipbrd;

procedure CaptureScreen(WholeDesktop: Boolean);
var
  Desktop: HWND;
  DesktopDC: HDC;
  FWidth, FHeight, FLeft, FTop: Integer;
  AImage: TBitmap;
  WindowRect: TRect;
  AFormat: Word;
  AData, APalette : THandle;
begin
  Desktop := GetDesktopWindow;

  AImage := TBitmap.Create;
  if WholeDesktop then
  begin
    FWidth := Screen.Width;
    FHeight := Screen.Height;
    FLeft := 1;
    FTop := 1;
  end else
  begin
    GetWindowRect(GetTopWindow(0), WindowRect);
    FWidth := WindowRect.Right - WindowRect.Left;
    FHeight := WindowRect.Bottom - WindowRect.Top;
    FLeft := WindowRect.Left;
    FTop := WindowRect.Top;
  end;

  DesktopDC := GetWindowDC(Desktop);
  try
    AImage.Width := FWidth;
    AImage.Height := FHeight;
    BitBlt(AImage.Canvas.Handle, 0, 0, FWidth, FHeight,
      DesktopDC, FLeft, FTop, SRCCOPY);
    AImage.SaveToClipBoardFormat(AFormat, AData, APalette);
    ClipBoard.SetAsHandle(AFormat, AData);
  finally
    ReleaseDC(Desktop, DesktopDC);
    AImage.Free;
  end;
end;

Shane
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 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