如何将JPG格式的图像放大和缩小,请高手指点!!! 如何将JPG格式的图像放大和缩小,请高手指点!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 转贴,请参考1、在Delphi IDE 中新建Project1(包含Form1s),在Form1上放置Image1、Label1。Image1.AutoSize为True,Label1.Align为alClient,Form1.WindowState为wsMaximized。2、程序代码如下。如欲感知键盘事件,可参照上述VB代码修改代码。unit Unit1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ExtCtrls, StdCtrls, jpeg, ComCtrls;typeTForm1 = 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;varForm1:TForm1;Old:Tpoint;ImageLeft:Integer;ImageTop:Integer;MoveOrNot:Boolean;implementationuses Unit2;{$R *.DFM}procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);beginif Button=mbLeft thenbeginLabel1.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);beginif MoveOrNot thenbeginImage1.Left:=ImageLeft+(X-Old.X);if (Image1.Left>=0) thenImage1.Left:=0else if (Image1.Left < Form1.Width-Image1.Width) thenImage1.Left:=Form1.Width-Image1.Width;Image1.Top:=ImageTop+(Y-Old.Y);if (Image1.Top>=0) thenImage1.Top:=0else if (Image1.Top < Form1.Height-Image1.Height) thenImage1.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);beginImage1.Left:=0;Image1.top:=0;end;end. 主要用的是Image的AutoSize功能等放大缩小之后,再另存即可 用Canvas 的StretchDraw方法就可以实现了,灵活、方便! Report Machine 分组 还是加载图片的问题 怎么解决我要取出数据库中最后的N条记录? 诚征使用Delphi监控用户对第三方程序GUI操作的方法 帮助文件制作 动态工资管理程序源代码(公式处理部分) 求救关于数据库输出为文本的问题(大哥大姐门我只有10了) 肥水不流外人田,MOP上有MM找BF了,还《很想找个程序员男朋友》 请问模式窗体显示问题:我有一个窗体想显示为模式窗体,但我的窗体格式设为了子窗体方式,现改为Normal方式,但还是不能显式 treeview控件的问题 奇怪的问题 急问 怎样在三层(socket连接)的客户端显示dbgrid读入数据的进度?
1、在Delphi IDE 中新建Project1(包含Form1s),在Form1上放置Image1、Label1。Image1.AutoSize为True,Label1.Align为alClient,Form1.WindowState为wsMaximized。
2、程序代码如下。如欲感知键盘事件,可参照上述VB代码修改代码。
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.