-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuniversalautosplit_main.pas
More file actions
116 lines (92 loc) · 2.83 KB
/
universalautosplit_main.pas
File metadata and controls
116 lines (92 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
unit UniversalAutoSplit_Main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Interfaces,
LCLType, LCLIntf, FPImage, IntfGraphics, Spin, StdCtrls, ComCtrls, GraphType,
UAS_ScreenUtils, UAS_GraphicUtils, UAS_SplitterLogic;
type
{ TFormMain }
TFormMain = class(TForm)
CheckBoxPreview: TCheckBox;
ImagePreview: TImage;
LabelInfo: TLabel;
SpinEditLeft: TSpinEdit;
SpinEditWidth: TSpinEdit;
SpinEditHeight: TSpinEdit;
SpinEditTop: TSpinEdit;
TimerScreenshot: TTimer;
UpDownSplitter: TUpDown;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TimerScreenshotTimer(Sender: TObject);
procedure UpDownSplitterClick(Sender: TObject; Button: TUDBtnType);
private
Splitter: TSplitter;
function NewImage: TLazIntfImage;
public
end;
var
FormMain: TFormMain;
implementation
{$R *.lfm}
{ TFormMain }
procedure TFormMain.TimerScreenshotTimer(Sender: TObject);
var
Screenshot, Preview: TLazIntfImage;
Rect: TRect;
startTime: cardinal;
cd: double;
begin
startTime := GetTickCount;
Rect.Left := SpinEditLeft.Value;
Rect.Top := SpinEditTop.Value;
Rect.Right := SpinEditWidth.Value + Rect.Left;
Rect.Bottom := SpinEditHeight.Value + Rect.Top;
Screenshot := NewImage;
TakeScreenshot(Screenshot, Rect);
if CheckBoxPreview.Checked then
begin
Preview := NewImage;
ScaleImage(Screenshot, Preview, ImagePreview.Width, ImagePreview.Height);
ImagePreview.Picture.Bitmap.LoadFromIntfImage(Preview);
Preview.Free;
end;
LabelInfo.Caption := FloatToStrF(Splitter.Process(Screenshot), ffFixed, 0, 3);
LabelInfo.Caption := LabelInfo.Caption + ' / ' +
IntToStr(GetTickCount - startTime) + 'ms';
LabelInfo.Caption := LabelInfo.Caption + ' / ' + Splitter.CurrentElement.Title;
Screenshot.Free;
Application.ProcessMessages;
end;
procedure TFormMain.UpDownSplitterClick(Sender: TObject; Button: TUDBtnType);
begin
Splitter.SetCurrentElement(UpDownSplitter.Position);
end;
procedure TFormMain.FormShow(Sender: TObject);
begin
TimerScreenshot.Enabled := True;
end;
procedure TFormMain.FormCreate(Sender: TObject);
begin
Splitter := TSplitter.Create('UniversalAutoSplit.ini');
UpDownSplitter.Max := Splitter.ElementCount - 1;
end;
procedure TFormMain.FormDestroy(Sender: TObject);
begin
Splitter.Free;
end;
function TFormMain.NewImage: TLazIntfImage;
var
RawImage: TRawImage;
begin
// create a TLazIntfImage with 32 bits per pixel, alpha 8bit, red 8 bit, green 8bit, blue 8bit,
// Bits In Order: bit 0 is pixel 0, Top To Bottom: line 0 is top
RawImage.Init;
RawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(0, 0);
RawImage.CreateData(False);
Result := TLazIntfImage.Create(0, 0);
Result.SetRawImage(RawImage);
end;
end.