imager.pas

来自「2003年的远程控制」· PAS 代码 · 共 64 行

PAS
64
字号
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 + =
减小字号Ctrl + -
显示快捷键?