饶世树鞭杆:delphi7编程技巧与实例精解之图形图像(修正重绘变形)
来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 02:24:53
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, ComCtrls, ExtCtrls, StdCtrls;typeTForm1 = class(TForm)img1: TImage;btn1: TButton;btn2: TButton;tmr1: TTimer;tb1: TTrackBar;dlgOpen1: TOpenDialog;rg1: TRadioGroup;procedure FormCreate(Sender: TObject);procedure tb1Change(Sender: TObject);procedure btn1Click(Sender: TObject);procedure tmr1Timer(Sender: TObject);procedure btn2Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;i: Integer;L,T,R,B: Integer;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);beginT:= Img1.Top;l:= img1.Left;b:= img1.Top+ img1.Height;r:= img1.Left+ img1.Width;end;procedure TForm1.tb1Change(Sender: TObject);begintmr1.Interval:= tb1.Position;end;procedure TForm1.btn1Click(Sender: TObject);vark: Integer;beginCanvas.Pen.Color:= Form1.Color;if rg1.ItemIndex<2 then beginfor k:= 0 to b do beginCanvas.MoveTo(0,k);Canvas.LineTo(r,k);end;end else if rg1.ItemIndex=2 then beginfor k:=0 to b+4 do beginCanvas.MoveTo(0,k);Canvas.LineTo(r,k);end;end;tmr1.Enabled:= True;i:= 0;end;procedure TForm1.tmr1Timer(Sender: TObject);varx,y: Integer;beginif rg1.ItemIndex=0 then beginSelf.Canvas.CopyRect(Rect(l,t+i,r,t+i+1),img1.Canvas,Rect(0,0+i,img1.Width,0+i+1));Self.Canvas.CopyRect(Rect(l,b-i,r,b-i+1),img1.Canvas,Rect(0,img1.Height-i,img1.Width,img1.Height-i+1));i:= i+1;if i>b/2-1 then tmr1.Enabled:= False;end else if rg1.ItemIndex=1 then beginSelf.Canvas.CopyRect(Rect(l,t+i*4,r,t+i*4+2),img1.Canvas,Rect(0,0+i*4,img1.Width,0+i*4+2));Self.Canvas.CopyRect(Rect(l,b-i*4-2,r,b-I*4),img1.Canvas,Rect(0,img1.Height-i*4-2,img1.Width,img1.Height-i*4));i:= i+1;if i>img1.Height/4 then tmr1.Enabled:= False;end else if rg1.ItemIndex=2 then beginfor x:= 0 to (img1.Width div 8 ) do beginfor y:= 0 to (img1.Height div 8 ) do begincase i of0: Self.Canvas.CopyRect(Rect(l+x*8,t+y*8,l+x*8+4,t+y*8+4),img1.Canvas,Rect(0+x*8,0+y*8,0+x*8+4,0+y*8+4));1: Self.Canvas.CopyRect(Rect(l+x*8+4,t+y*8+4,l+x*8+8,t+y*8+8),img1.Canvas,Rect(0+x*8+4,0+y*8+4,0+x*8+8,0+y*8+8));2: Self.Canvas.CopyRect(Rect(L+x*8,t+y*8+4,l+x*8+4,t+y*8+8),img1.Canvas,Rect(0+x*8,0+y*8+4,0+x*8+4,0+y*8+8));3: Self.Canvas.CopyRect(Rect(l+x*8+4,t+y*8,l+x*8+8,t+y*8+4),img1.Canvas,Rect(0+x*8+4,0+y*8,0+x*8+8,0+y*8+4));end;end;end;i:= i+1;if i>3 then tmr1.Enabled:= False;end;end;procedure TForm1.btn2Click(Sender: TObject);beginif not dlgOpen1.Execute then Exit;img1.Picture.LoadFromFile(dlgOpen1.FileName);T:= Img1.Top;l:= img1.Left;b:= img1.Top+ img1.Height;r:= img1.Left+ img1.Width;end;end.
delphi7编程技巧与实例精解之图形图像(修正重绘变形)
文件夹变形 windows C 编程 一个实例
电话营销技巧与实例
电话营销技巧与实例
数控车床编程实例
Linux信号量编程实例
Bash编程实例 一
Linux信号量semaphore编程实例
数控车床编程实例(KND系统)
《PhotoShop技巧与实例第22011教程》
PS教程与技巧、 操作实例大全
PS教程与技巧、操作实例大全
升级技巧与实例分析(7)
PS中操控变形的应用_Photoshop CS5:内容识别和操控变形_设计天堂技巧_电脑之...
推动浪与修正浪——固重:波段套利 快乐投资
Firebug调试经验与技巧-开发工具-编程环境
复杂3-D曲面编程的方法与技巧1
复杂3-D曲面编程的方法与技巧2
MACD实战修正技巧
图形图像技巧——怎样让照片开口说话?
重号与连号选择技巧
面向接口编程详解(二)——编程实例
数控编程实例:FANUC系统宏程序编程
税收之重与转型之痛