如何将JPG格式的图像放大和缩小,请高手指点!!!!

解决方案 »

  1.   

    转贴,请参考
    1、在Delphi IDE 中新建Project1(包含Form1s),在Form1上放置Image1、Label1。Image1.AutoSize为True,Label1.Align为alClient,Form1.WindowState为wsMaximized。
    2、程序代码如下。unit Unit1;
    interface
    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    ExtCtrls, StdCtrls, jpeg, ComCtrls;
    type
    TForm1 = class(TForm)
    Image1: TImage;
    Label1: TLabel;
    procedure Label1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    procedure Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    procedure Label1MouseUp(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    procedure FormShow(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;
    var
    Form1:TForm1;
    Old:Tpoint;
    ImageLeft:Integer;
    ImageTop:Integer;
    MoveOrNot:Boolean;
    implementation
    uses Unit2;
    {$R *.DFM}
    procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    begin
    if Button=mbLeft then
    begin
    Label1.Cursor:=crHandPoint;
    Old.X:=X;
    Old.Y:=Y;
    ImageLeft:=Image1.Left;
    ImageTop:=Image1.Top;
    MoveOrNot:=True;
    end;
    end;
    procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    begin
    if MoveOrNot then
    begin
    Image1.Left:=ImageLeft+(X-Old.X);
    if (Image1.Left>=0) then
    Image1.Left:=0
    else if (Image1.Left < Form1.Width-Image1.Width) then
    Image1.Left:=Form1.Width-Image1.Width;
    Image1.Top:=ImageTop+(Y-Old.Y);
    if (Image1.Top>=0) then
    Image1.Top:=0
    else if (Image1.Top < Form1.Height-Image1.Height) then
    Image1.Top:=Form1.Height-Image1.Height;
    end;
    end;
    procedure TForm1.Label1MouseUp(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    begin
    // MoveOrNot:=False;
    Label1.Cursor:=crDefault;
    end;
    procedure TForm1.FormShow(Sender: TObject);
    begin
    Image1.Left:=0;
    Image1.top:=0;
    end;
    end.
      

  2.   

    将其转为BMP格式,然后再调整大小
    之后再保存为JPG的格式