📄 178.htm
字号:
<!-- saved from url=(0022)http://internet.e-mail -->
<html>
<head>
<title>使图片旋转 </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc.css">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="195434" alink="195434">
<table width="621" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="621"><a href="http://www.CoDelphi.com"><img src="images/logo.gif" border="0" width="153" height="60"><img src="images/bigbanner.gif" border="0" width="468" height="60"></a></td>
</tr>
</table><br>
<br>
<table width="621" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="left" valign="top" class="font9" height="155">
<div align="center" class="btitle">使图片旋转 <br>
<br>
</div>
<div align="center"><strong>CoDelphi.com </strong></div>
<b><br>
摘 要</b>:如何使图片旋转 <br>
<b> 关键字</b>:Canvas 自由旋转 旋转 <br>
<b> 类 别</b>:图形
<hr size="1" width="100%">
<span class="content"><br><br>在窗体中添加一个button和一个image,选择一幅大约100x100的bitmap。<br><br>unit drawunit; <br><br>interface <br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, ExtCtrls; <br><br>type<br> TForm1 = class(TForm)<br> Image1: TImage;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> private<br> { Private declarations }<br> public<br> rotateimage:timage;<br> end; <br><br>var<br> Form1: TForm1; <br><br>implementation <br><br>{$R *.DFM} <br><br>procedure TForm1.Button1Click(Sender: TObject); <br>const<br> rotation = 2/3*pi; <br>var<br> x,y : integer;<br> newx,newy : integer;<br> radius,a : real; <br>begin<br> form1.WindowState:=wsMaximized;<br> image1.Visible:=false;<br> button1.Visible:=false;<br> rotateimage:=timage.Create(self);<br> rotateimage.parent:=self;<br> rotateimage.Left:=0;<br> rotateimage.Top:=0;<br> rotateimage.width:=740;<br> rotateimage.Height:=540;<br> for x:=1 to image1.Picture.Width do<br> begin<br> for y:=1 to image1.Height do<br> begin<br> radius:=Sqrt(Sqr(X)+Sqr(Y));<br> a:=Arctan(Y/X);<br> newx:=round(Radius*Cos(A+Rotation)+300);<br> newy:=round(Radius*Sin(A+Rotation)+300);<br> rotateimage.Canvas.Pixels[newx,newy]:=image1.Canvas.Pixels[x,y];<br> end;<br> end; <br>end; <br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); <br>begin<br> rotateimage.free; <br>end; <br><br>end.</span>
<table border="0" cellspacing="0" cellpadding="1" class="font9" align="center" width="100%">
<tr align="left" valign="middle" bgcolor="195434">
<td height="1"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#C9C9C6" height="2"></td>
</tr>
</table>
<div align="center"><br>
中文开发在线<a href="http://www.codelphi.com" target="_blank">www.codelphi.com</a>授权使用。
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -