ImageEn, unit imageenio

TIECSSource


Declaration

TIECSSource = (iecsScreen, iecsPrimary, iecsForegroundWindow, iecsForegroundWindowClient, iecsForegroundWindow2, iecsSpecifiedWindow, iecsSpecifiedWindowClient, iecsSpecifiedWindow2, iecsSpecifiedMonitor);


Description

Capture methods available via CaptureFromScreen:
Value Description
iecsScreen Capture the entire screen (all screens on a multiple monitor system)
iecsPrimary Capture the screen of the primary monitor on a multiple monitor system (or the whole screen if there is only one monitor)
iecsForegroundWindow Capture the active window
iecsForegroundWindowClient Capture the client area of the active window
iecsForegroundWindow2 Capture the screen area of the active window (alternative to iecsForegroundWindow)
iecsSpecifiedWindow Capture the window of the specified handle
iecsSpecifiedWindowClient Capture the client area of the window of the specified handle
iecsSpecifiedWindow2 Capture the screen area of the window of the specified handle (if other windows are overlapping, they will be visible). This works better with some window types that do not support iecsSpecifiedWindow
iecsSpecifiedMonitor Capture the screen of the specified monitor on a multiple monitor system (pass monitor index as Window parameter. Valid range is 0 to Screen.MonitorCount - 1)


Demos

Demo  Demos\InputOutput\CaptureFromScreen\CaptureFromScreen.dpr
Demo  Demos\VideoCapture\DesktopToAvi\DesktopToAvi.dpr
Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr


Examples

// Save the current desktop to 'screen.png'
ImageEnView1.IO.CaptureFromScreen( iecsScreen, -1 );
ImageEnView1.IO.SaveToFile( 'D:\screen.png' );

// Capture the content of the window with the title, "Untitled - Notepad"
NotepadHandle := FindWindow( nil, 'Untitled - Notepad' );
if NotepadHandle <> 0 then
  ImageEnView1.IO.CaptureFromScreen( iecsSpecifiedWindow, crDefault, NotepadHandle );

// Capture the content of the active Windows settings window (iecsSpecifiedWindow2 works better with some windows types)
handle := FindWindow( nil, 'Settings' );
SetForegroundWindow( handle ); // Ensure no other window overlaps desired one
if NotepadHandle <> 0 then
  ImageEnView1.IO.CaptureFromScreen( iecsSpecifiedWindow2, crDefault, handle );

// Capture each screen of a multi-monitor system and save to file
for i := 0 to Screen.MonitorCount - 1 do
begin
  ImageEnView1.IO.CaptureFromScreen( iecsSpecifiedMonitor, -1, i );
  ImageEnView1.IO.SaveToFile( format( 'D:\Screen_%d.jpeg', [ i ]));
end;

// Capture primary monitor to a TBitmap
var
  bmp: TBitmap;
  IO: TImageEnIO;
begin
  bmp := TBitmap.Create;
  IO := TImageEnIO.CreateFromBitmap( bmp );
  try
    IO.CaptureFromScreen( iecsPrimary );
    ... do something with bmp ...
  finally
    IO.Free;
    bmp.Free;
  end;
end;