如何在Delphi平台上实现图像放大镜
|
源代码网整理以下在一些常用的看图软件中都带有一个可以放大局部图像的功能,本实例就是为模仿这一功能开发的。 源代码网整理以下向窗体上添加两个TImage组件,其中一个TImage组件的Name属性设置为Image1,它充当原图片显示的载体。另一个TImage组件的Name属性设置为Image2,它可以显示放大后的图像。 源代码网整理以下本例的核心是StretchBlt函数,利用StretchBlt函数实现局部图像放大,响应代码如下: 源代码网整理以下 源代码网整理以下 begin 软件开发网 www.mscto.com 源代码网整理以下 StretchBlt(Image2.Canvas.Handle,0,0,Image2.Width,Image2.Height, 源代码网整理以下 Image1.Canvas.Handle, X-20,Y-20,40,40,SRCCOPY); 软件开发网 www.mscto.com
源代码网整理以下 Image2.Refresh; 软件开发网 www.mscto.com
源代码网整理以下 Screen.Cursors[1]:=LoadCursorFromFile(’MAGNIFY.CUR’); 源代码网整理以下 Self.Cursor:=1; 源代码网整理以下 end; 源代码网整理以下 源代码网整理以下程序代码如下: 源代码网整理以下 源代码网整理以下 interface 源代码网整理以下 uses 源代码网整理以下 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 源代码网整理以下 Dialogs, ExtCtrls, StdCtrls; 源代码网整理以下 type 源代码网整理以下 TForm1 = class(TForm) 源代码网整理以下 Image1: TImage; 源代码网整理以下 Image2: TImage; 源代码网整理以下 procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer); 源代码网整理以下 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer); 源代码网整理以下 private 软件开发网 www.mscto.com 源代码网整理以下 { Private declarations } 源代码网整理以下 public 软件开发网 www.mscto.com 源代码网整理以下 { Public declarations } 源代码网整理以下 end; 源代码网整理以下 var 源代码网整理以下 Form1: TForm1; 源代码网整理以下 implementation 源代码网整理以下 {$R *.dfm} 源代码网整理以下 procedure TForm1.Image1MouseMove(Sender:TObject;Shift:TShiftState;X,Y: Integer); 源代码网整理以下 begin 源代码网整理以下 StretchBlt(Image2.Canvas.Handle,0,0,Image2.Width,Image2.Height,Image1.Canvas.Handle, X-20,Y-20,40,40,SRCCOPY); 源代码网整理以下 Image2.Refresh; 源代码网整理以下 Screen.Cursors[1]:=LoadCursorFromFile(’MAGNIFY.CUR’); 源代码网整理以下 Self.Cursor:=1; 源代码网整理以下 end; 软件开发网 www.mscto.com 源代码网整理以下 procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer); 源代码网整理以下 begin 源代码网整理以下 Screen.Cursors[1]:=crDefault; 源代码网整理以下 Self.Cursor:=1; 软件开发网 www.mscto.com 源代码网整理以下 end; 源代码网整理以下 end. 源代码网整理以下放大图像是一个优秀的看图软件必备的功能,本实例提供了一种非常简便易行的方法,不但代码数量少,而且执行效率高 软件开发网 www.mscto.com 源代码网推荐 源代码网供稿. |
