Screen Scanner - Psychlo

Submitted by:David Villa

Date added:13 February, 2014

Category:Delphi

Just got inspired last night and decided to start a class to get the screen in "blocks" and check which one has changed to update only those.

Tags: screen , scanner

Code Snippet:

(* ********************************
* uScreenScanner.pas *
* version: 1.0 *
* by Psychlo *
* *
* Thanks to: *
* iC0de Community *
* Torry's Delphi Page *
* givex8 *
* Protocol *
* dn5 *
******************************** *)

unit uScreenScanner;

interface

uses
Windows, SysUtils, Graphics;

const
ERRORMSG_INCORRECT_WIDTH = 'Width must be multiple of 8!';
ERRORMSG_INCORRECT_HEIGHT = 'Height must be multiple of 8!';

type
TBmpPack = packed record
Bmp: TBitmap;
Modified: Boolean;
end;
TBmpArray = Array of TBmpPack;

TScreenScanner = class

private
fDivScreen: Integer;
fScreenWidth, fScreenHeight: Integer;
fWatchRect: TRect;
fScreenArray: Array of TBmpArray;

function CompareBitmap(Bmp1, Bmp2 : TBitmap): Integer;
published
constructor Create(
const DivScreen: Integer = 8;
const X: Integer = 0;
const Y: Integer = 0;
const Width: Integer = 0;
const Height: Integer = 0
);

destructor Destroy; override;

procedure ScanScreen;
function GetSnapshot(lpRect: TRect): TBitmap;
function GetBitmapRect(lpRect: TRect; Bitmap: TBitmap): TBitmap;
function GetBmpPack(i, j: Integer): TBmpPack;
function IsBmpPackModified(i, j: Integer): Boolean;

property ColumnCount: Integer read fDivScreen;
property RowCount: Integer read fDivScreen;
property ScreenWidth: Integer read fScreenWidth;
property ScreenHeight: Integer read fScreenHeight;
end;

implementation
//... to be continued in attachment ;) ...
 
 

Comments