/**
Code adapted from CxImage (http://www.xdp.it/cximage.htm)
*/
static BYTE*
Rotate90(BYTE *src, int src_width, int src_height, int bpp ) {
int x, y, y2;
int dst_width = src_height;
int dst_height = src_width;
// get src and dst scan width
int src_pitch = (src_width*bpp + 7) /8 + 3 & ~3;
int dst_pitch = (dst_width*bpp + 7) /8 + 3 & ~3;
// allocate dst image
BYTE *dst = new BYTE[dst_pitch * dst_height];
if(NULL == dst) return NULL;
if(bpp == 1) {
// speedy rotate for BW images
BYTE *sbits, *dbits, *dbitsmax, bitpos, *nrow, *srcdisp;
div_t div_r;
BYTE *bsrc = src;
BYTE *bdest = dst;
dbitsmax = bdest + dst_height * dst_pitch - 1;
for(y = 0; y < src_height; y++) {
// figure out the column we are going to be copying to
div_r = div(y, 8);
// set bit pos of src column byte
bitpos = (BYTE)(128 >> div_r.rem);
srcdisp = bsrc + y * src_pitch;
for (x = 0; x < src_pitch; x++) {
// get source bits
sbits = srcdisp + x;
// get destination column
nrow = bdest + (dst_height - 1 - (x * 8)) * dst_pitch + div_r.quot;
for (int z = 0; z < 8; z++) {
// get destination byte
dbits = nrow - z * dst_pitch;
if ((dbits < bdest) || (dbits > dbitsmax)) break;
if (*sbits & (128 >> z)) *dbits |= bitpos;
}
}
}
}
else if((bpp == 8) || (bpp == 24) || (bpp == 32)) {
}
return dst;
}
(顺时针)旋转BW图像程序
原创mb63982c735c3d9 ©著作权
©著作权归作者所有:来自51CTO博客作者mb63982c735c3d9的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
有趣的CSS - 旋转的金币
今天分享的是一个旋转的金币,适用于游戏网站,会员币等场景。
css 旋转的金币 动效 ux 用户体验 -
有趣的CSS - 旋转的太极图
用css画一个旋转的太极图。
css html 伪元素 -
android 图像顺时针转90 顺时针旋转flash
今天用了几个小时的时间,用Flash做了一个时钟。刚做的时候上风找了很多的资料都没办法解决问题。最后还是靠自己的尝试,终于都搞出来了。现在过程记录如下。做出来的效果如下: 制作过程如下: 1、先用PS把底图做出来,也就是除了三根转动的时针。 2、用PS制
android 图像顺时针转90 flash date 测试 function