ImageEn, unit imageenio

TIECSSource


Declaration

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


Description

Used by CaptureFromScreen

Value Description
iecsScreen Captures the entire screen (all screens on a multiple monitor system)
iecsPrimary Captures the screen of the primary monitor on a multiple monitor system (or the whole screen if there is only one monitor)
iecsForegroundWindow Captures the active window
iecsForegroundWindowClient Captures the client area of the active window
iecsForegroundWindow2 Captures the screen area of the active window (alternative to iecsForegroundWindow)
iecsSpecifiedWindow Captures the window of the specified handle
iecsSpecifiedWindowClient Captures the client area of the window of the specified handle
iecsSpecifiedWindow2 Captures 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 Captures 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)


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 window 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;