超级难题,如何实现Image的任意角度的旋转。

ming1 2000-09-11 12:03:00
本人最近多次提出此问题,可是至今没有人能够解决,难以找到实现Image 任意角度的旋转,那位高手有算法、思路请详细指教,70分可不是小数!
...全文
294 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hank 2000-12-11
  • 打赏
  • 举报
回复
你难道没有下载我说的控件吗,有现成的例子及DEMO!

http://www.crosswinds.net/~khojasteh/delphi-components.html

TRotateImage v1.21
This component is a visual component similar to TImage with ability to rotate the image in any arbitrary angle. TRotateImage can be used on Delphi 3, 4, and 5.
noall 2000-12-11
  • 打赏
  • 举报
回复
那个过程怎么调用呢?如何体现呢?
比如说旋转后的图放在另外一个Timage控件中,该怎么办呢?
Hank 2000-11-29
  • 打赏
  • 举报
回复
http://www.crosswinds.net/~khojasteh/delphi-components.html

TRotateImage v1.21
This component is a visual component similar to TImage with ability to rotate the image in any arbitrary angle. TRotateImage can be used on Delphi 3, 4, and 5.
stamf 2000-09-13
  • 打赏
  • 举报
回复
我看那个代码可能会产生冗余点和漏失点,还要用插值法进行处理,要不有些难看
shines77 2000-09-13
  • 打赏
  • 举报
回复
这就是想笑的原因,因为上面的一段代码也是他自己写出来的,当然不是他写的:)
tchaikov 2000-09-13
  • 打赏
  • 举报
回复
to: shines
你怎么把我的话也抄上去了?哈哈!
不过,这是真的,如果真的按下面下矩阵计算每个点,目标区有一些点会是白点(因为有些源点通过计算和四舍五入在目标中凑到一起了),我以前解决的办法是从目标求的源点的坐标和像素值,不过首先要取到目标区的区域(往往是斜的)。
cos(Alpha), sin(Alpha), 0
-sin(Alpha),cos(Alpha), 0
0, 0, 1

to: ming1
你还没有搞定?不是有人已经替你解释了吗?实在不行,一个点一个点算吧,等画出来了再考虑速度问题。

shines77 2000-09-13
  • 打赏
  • 举报
回复
如果你发现转过来的图形带有很整齐的花点,解决的办法是反向计算,即从目标求的源点的坐标和像素值。
以上的例子就是这样的。

:)))
shines77 2000-09-13
  • 打赏
  • 举报
回复
procedure Rotate(Bmp,Dst:TFastRGB;cx,cy:Integer;Angle:Extended);
var
cAngle,
sAngle: Double;
xDiff,
yDiff,
xpr,ypr,
ix,iy,
px,py,
x,y: Integer;
Tmp: PFColor;{what means?}
begin
Angle:=-Angle*Pi/180;
sAngle:=Sin(Angle);
cAngle:=Cos(Angle);
xDiff:=(Dst.Width-Bmp.Width)div 2;
yDiff:=(Dst.Height-Bmp.Height)div 2;
Tmp:=Dst.Bits;{what means?}
for y:=0 to Dst.Height-1 do
begin
py:=2*(y-cy)+1;
for x:=0 to Dst.Width-1 do
begin
px:=2*(x-cx)+1;
xpr:=Round(px*cAngle-py*sAngle);
ypr:=Round(px*sAngle+py*cAngle);
ix:=((xpr-1)div 2+cx)-xDiff;
iy:=((ypr-1)div 2+cy)-yDiff;
if(ix>-1)and(ix<Bmp.Width)and(iy>-1)and(iy<Bmp.Height)then
Tmp^:=Bmp.Pixels[iy,ix]; {what means?}
Inc(Tmp);
end;
Tmp:=Pointer(Integer(Tmp)+Dst.Gap); {what means?}
end;
end;

原理:
cos(Alpha), sin(Alpha), 0
只需要用源矩阵乘以 -sin(Alpha),cos(Alpha), 0
0, 0, 1

呵呵:))哈哈:))
Putao 2000-09-13
  • 打赏
  • 举报
回复
关注

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧