社区
游戏开发
帖子详情
图象旋转的数学算法
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种常用图像处理
算法
(函数)
文章含有8种图像处理
算法
,每一行都有很详细的解释!
基于GPU并行处理的图像快速
旋转
算法
.pdf
基于GPU并行处理的图像快速
旋转
算法
.pdf
图片
旋转
算法
[项目代码]
本文介绍了一种实现图片逆时针
旋转
90度的
算法
。该
算法
通过内存分配和拷贝操作,将原始图片数据存储到临时缓冲区,然后通过三重循环重新排列像素位置,实现
旋转
效果。核心代码展示了如何计算目标图像的宽度和高度,以及如何进行像素数据的重新映射。
算法
最后释放临时内存并返回操作状态。该实现适用于多通道图像(如RGB),通过调整channel参数可适应不同格式。
旋转
、反射和扭曲图像
Example049-
旋转
、反射和扭曲图像
游戏开发
8,324
社区成员
23,684
社区内容
发帖
与我相关
我的任务
游戏开发
游戏开发相关内容讨论专区
复制链接
扫一扫
分享
社区描述
游戏开发相关内容讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章