Solved

Taking Screenshots for Processing in Delphi.

Posted on 2004-04-05
2
306 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
  • 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 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now