📄 imager.pas
字号:
unit imager;
interface
uses Windows,Forms, Graphics, jpeg, ExtCtrls, Classes, Controls;
type
Tvjpeg = class(TForm)
Image1: TImage;
procedure OpenFile(const Filename: string;rescale:single=1);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
uses main;
{$R *.DFM}
procedure Tvjpeg.OpenFile(const Filename: string;rescale:single=1);
var outputx,outputy:integer;
scale:single;
wind:hwnd;
begin
Form1.Caption:='Jpeg Image '+filename;
try
Image1.Picture.LoadFromFile(Filename);
except
on EInvalidGraphic do
begin
{Image1.Picture.Graphic := nil;}
exit;
end;
else exit;
end;
Scale := Image1.Picture.Height / (Rescale*Image1.Picture.Width);
outputx:=screen.width;
outputy:=Trunc(outputx*Scale);
if outputy>screen.height then
begin
outputy:=screen.height;
outputx:=Trunc(outputy/Scale);
end;
image1.left:=(screen.width-outputx) div 2;
image1.width:=outputx;
image1.top:=(screen.height-outputy) div 2;
image1.height:=outputy;
show;
wind:=self.Handle;
setwindowpos(wind,HWND_TOPMOST,0,0,screen.width,screen.height,SWP_SHOWWINDOW);
end;
procedure Tvjpeg.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
hide;
Canclose:=true;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -