图象旋转的数学算法

Appla 2001-07-25 11:13:06
我需要一个完整的图象旋转算法,不吝赐教
...全文
94 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
rockswang 2001-07-25
  • 打赏
  • 举报
回复
WannaPlayDIB图形函式库,源代码开放。
http://wannaplay.51.net/products.html

POWERPIGGY 2001-07-25
  • 打赏
  • 举报
回复
快速黑白图象旋转
DLLIMPORT void WINAPI RotateImage( BYTE _huge *Image , BYTE _huge *RotatedImage,
double theta , unsigned ImageWidth , unsigned ImageHeight )

{
unsigned ImageCol, ImageRow ;
int CenterCol,CenterRow, SPixelColNum,SPixelRowNum;
double CosAngle,SinAngle,SPixelColAddr,SPixelRowAddr;
double ColDelta,RowDelta,dsin,dcos,Dsin,Dcos;
double SPixelX,SPixelY;
double see1;
double see2;
__int16 DestByte,Pixel;
__int16 flag;
__int16 width=ImageWidth;
__int16 height=ImageHeight;
int xx,yy;
BYTE mask;

unsigned Bytes = ( ImageWidth + 7) >> 3 ;
__int16 sourptr=0,destptr=0,destptr1=ImageHeight*Bytes;
if (fabs(theta)<0.000002)
{
memcpy(RotatedImage,Image,Bytes * ImageHeight);
return;
}
CosAngle= cos(theta);
SinAngle= sin(theta);
CenterCol= (ImageWidth+1)/2;
CenterRow= (ImageHeight+1)/2;
memset(RotatedImage,0,Bytes * ImageHeight);
dsin=-CenterRow * SinAngle;
dcos=-CenterRow * CosAngle;
Dcos = -CenterCol * CosAngle;
Dsin = -CenterCol * SinAngle;
//saveoldimage(Image,ImageWidth,ImageHeight);


_asm{
push ds
push es
pusha

finit
fstcw flag
//mov bx,62463
fwait
and flag,0f3ffH ///1111001111111111b
fldcw flag

fld CosAngle
fld SinAngle
fld dcos
fld dsin
fwait
xor cx,cx
L1:
cmp cx,height
jae ENDLOOP
push cx
//fld st(4) ///????
//fld st(4) ///????
xor dx,dx
fld Dcos
fld Dsin
fwait
L2:
cmp dx,width
jae NEXTLOOP
push dx

fld st(1) ///?????
//fst see1 //lfz1998.9.7
fsub st,st(3) ///?????
fiadd CenterCol

fist xx ///x
ffree st
mov ebx,xx

fld st(1) ///?????
fadd st,st(5) ///?????
fiadd CenterRow

fist yy
ffree st
fwait
mov eax,yy ///y

//cmp ebx,0
//jb L3
cmp ebx,ImageWidth
jae L3
//cmp eax,0
//jb L3
cmp eax,ImageHeight
jae L3
imul eax,ImageWidth
add eax,ebx
shr eax,3
add eax,Image
mov dl,BYTE ptr[eax]
cmp dl,0
jz L3
lll: mov al,10000000b
mov cl,bl
and cl,00000111b
shr al,cl
and al,dl
jz L3
xor eax,eax
xor ebx,ebx
pop bx
pop ax
push ax
push bx
imul eax,ImageWidth
add eax,ebx
shr eax,3
add eax,RotatedImage
mov dl,BYTE ptr [eax]
mov cl,bl
mov bl,10000000b
and cl,00000111b
shr bl,cl
or dl,bl
mov Byte ptr [eax],dl

L3:
fincstp
fincstp
fincstp
fadd st,st(4)
fdecstp
fadd st,st(4)
fwait
pop dx
inc dx
jmp L2
NEXTLOOP: pop cx
inc cx


fincstp
fincstp

fadd st,st(2)
fincstp
fadd st,st(2)
fdecstp
ffree st(7)
ffree st(6)
jmp L1
ENDLOOP:
ffree st(0)
ffree st(1)
ffree st(2)
ffree st(3)
ffree st(4)
ffree st(5)
ffree st(6)
ffree st(7)

popa
pop es
pop ds

}

}

8,324

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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