高手请进:这个任意旋转Image的函数好难懂
ming1 2000-09-05 11:31:00 本人从网上下载一个旋转image的程序,很爽,可是就是很看懂程序,那位
高手能给我做精彩分解,谢谢。
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;