-
Notifications
You must be signed in to change notification settings - Fork 25
/
histoform.pas
executable file
·120 lines (99 loc) · 2.87 KB
/
histoform.pas
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
117
118
119
120
unit histoform;
interface
uses
{$IFNDEF Unix} Windows,{$ENDIF}
{$IFDEF FPC} LResources,{$ENDIF}
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ExtCtrls,ClipBrd;
type
{ THistogramForm }
THistogramForm = class(TForm)
HistoPanel: TScrollBox;
HistoImage: TImage;
MainMenu1: TMainMenu;
File1: TMenuItem;
Edit1: TMenuItem;
Copy1: TMenuItem;
Saveasbitmap1: TMenuItem;
Closewindow1: TMenuItem;
procedure Copy1Click(Sender: TObject);
procedure Closewindow1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Saveasbitmap1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
HistogramForm: THistogramForm;
implementation
{$IFNDEF FPC}
{$R *.DFM}
{$ENDIF}
uses nifti_img, nifti_img_view;
procedure THistogramForm.Copy1Click(Sender: TObject);
{$IFDEF FPC}
begin
if (HistoImage.Picture.Graphic = nil) then begin //1420z
Showmessage('You need to load an image before you can copy it to the clipboard.');
exit;
end;
HistoImage.Picture.Bitmap.SaveToClipboardFormat(2);
end;
{$ELSE}
var
MyFormat : Word;
AData: THandle;
APalette : HPalette; //For later versions of Delphi: APalette : THandle;
begin
if (HistoImage.Picture.Graphic = nil) then begin //1420z
Showmessage('You need to load an image before you can copy it to the clipboard.');
exit;
end;
HistoImage.Picture.SaveToClipBoardFormat(MyFormat,AData,APalette);
ClipBoard.SetAsHandle(MyFormat,AData)
end;
{$ENDIF}
procedure THistogramForm.Closewindow1Click(Sender: TObject);
begin
HistogramForm.Close;
end;
procedure THistogramForm.FormCreate(Sender: TObject);
begin
{$IFDEF Darwin}
{$IFNDEF LCLgtk} //only for Carbon compile
Copy1.ShortCut := ShortCut(Word('C'), [ssMeta]);
Saveasbitmap1.ShortCut := ShortCut(Word('S'), [ssMeta]);
Closewindow1.ShortCut := ShortCut(Word('W'), [ssMeta]);
{$ENDIF}
{$ENDIF}
end;
procedure THistogramForm.FormHide(Sender: TObject);
begin
{$IFDEF Darwin}Application.MainForm.SetFocus;{$ENDIF}
end;
procedure THistogramForm.FormResize(Sender: TObject);
begin
DrawHistogram(gMRIcroOverlay[ImgForm.ActiveLayer],HistogramForm.HistoImage);
end;
procedure THistogramForm.FormShow(Sender: TObject);
begin
//HistogramForm.Caption := inttostr(HistogramForm.HistoImage.Width);
end;
procedure THistogramForm.Saveasbitmap1Click(Sender: TObject);
begin
{$IFNDEF FPC}
SaveImgAsPNGBMP (HistoImage);
{$ELSE}
SaveImgAsPNGBMP (HistoImage);
{$ENDIF}
end;
{$IFDEF FPC}
initialization
{$I histoform.lrs}
{$ENDIF}
end.