24位位图旋转90度

1、顺时针旋转90度

void RGB24RotateClockwise90(uint8_t* src,uint8_t* dst, int width, int height)
{
	int w;
	int h;
	int src_row_bytes;
	int dst_row_bytes;
	uint8_t* img;
	uint8_t* ptr;
	int i, j;
	unsigned int size;
	unsigned int off1;
	unsigned int off2;
	int off;

	w = height;
	h = width;
	src_row_bytes = (width * 3 + 3) & ~3;
    dst_row_bytes = (w * 3 + 3) & ~3;

	off1  = 0;
	off2 = (w - 1) * 3;
	for(i = 0; i < height; i++)
	{   
		img = src + off1;
		ptr = dst + off2;
		for(j = 0; j < width; j++)
		{
			ptr[0] = img[0];
			ptr[1] = img[1];
			ptr[2] = img[2];
	        img += 3;
			ptr += dst_row_bytes;
		}
		off1 += src_row_bytes;
		off2 = (w - i - 1) * 3;
	}
}


2、逆时针旋转90度:

void RGB24RotateAnticlockwise90(uint8_t* src,uint8_t* dst, int width, int height)
{
	int w;
	int h;
	int src_row_bytes;
	int dst_row_bytes;
	unsigned char* img;
	unsigned char* ptr;
	int i, j;
	unsigned int off1;
	unsigned int off2;

	w = height;
	h = width;
	src_row_bytes = (width * 3 + 3) & ~3;
	dst_row_bytes = (w * 3 + 3) & ~3;

	off1  = (width - 1) * 3;
	off2 =  0;;
	for(i = 0; i < height; i++)
	{   
		img = src + off1;
		ptr = dst + off2;
		for(j = 0; j < width; j++)
		{
			ptr[0] = img[0];
			ptr[1] = img[1];
			ptr[2] = img[2];
			img -= 3;
			ptr += dst_row_bytes;
		}
		off1 += src_row_bytes;
		off2 = i * 3;
	}
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值