Solved

Taking Screenshots for Processing in Delphi.

Posted on 2004-04-05
2
305 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

22 Experts available now in Live!

Get 1:1 Help Now