最近用到了图像向左或者向右旋转90°的情况,纠结了好一会儿,写下来供大家参考。

1 向左旋转90°

//unsigned char *pImgData: 输入图像指针
//int WidthIn, int HeightIn:输入图像宽、高
//unsigned char *pImgOut: 旋转后图像指针
void RotateOfLeft(unsigned char *pImgData, int WidthIn, int HeightIn)
{
int i, j, tempSize;
int WidthOut = HeightIn;
int HeightOut = WidthIn;
unsigned char pImgtemp[*];
for (i = ; i < HeightIn; i ++)
{
for (j = ;j < WidthIn; j ++)
{
*(pImgtemp + i*WidthIn + j) = *(pImgData*WidthIn + j);
}
}
//memcpy(pImgtemp,pImgData,148*36);
for (i = ; i < HeightOut; i ++)
{
for (j = ;j < WidthOut; j ++)
{
*(pImgData + i*WidthOut + j) = *(pImgtemp + (j+)*WidthIn - - i);
}
}
}

2 向右旋转90°

//unsigned char *pImgData: 输入图像指针
//int WidthIn, int HeightIn:输入图像宽、高
//unsigned char *pImgOut: 旋转后图像指针
void RotateOfRight(unsigned char *pImgData, int WidthIn, int HeightIn, unsigned char *pImgOut)
{
int i, j;
int WidthOut = HeightIn;
int HeightOut = WidthIn;
for (i = ; i < HeightOut; i ++)
{
for (j = ;j < WidthOut; j ++)
{
*(pImgOut + i*WidthOut + j) = *(pImgData + (HeightIn - j - 1)*WidthIn + i);
}
}
}

最新文章

  1. java socket传送一个结构体给用C++编写的服务器解析的问题
  2. Json.net对于导航属性的处理(解决对象循环引用)
  3. 【转】drupal7请求异常,执行时间过长的解决方法
  4. 插入中文错误ERROR 1406 (22001): Data too long for column &#39;name&#39; at row 1
  5. 转!数据库连接池概念、种类、配置(DBCP\C3P0\JndI与Tomact配置连接池)
  6. Android Calendar获取年月日时分秒毫秒
  7. Atom编辑器入门到精通(四) Atom使用进阶
  8. leetcode面试准备:Multiply Strings
  9. redundant 行记录格式
  10. 利用USearch去除嵌合体(chimeras)
  11. BZOJ 2806: [Ctsc2012]Cheat [广义后缀自动机 单调队列优化DP 二分]
  12. same tree(判断两颗二叉树是否相等)
  13. WPF防止界面卡死并显示加载中效果
  14. Brute-forced Euclid Distance Transform
  15. Dubbo 服务集群容错配置
  16. go微服务框架go-micro深度学习(四) rpc方法调用过程详解
  17. unity3d射线控制移动
  18. nginx封ip,禁用IP段的设置说明
  19. django数据库操作-增删改查-多对多关系以及一对多(外键)关系
  20. atitit.spring hibernate的事务机制 spring不能保存对象的解决

热门文章

  1. Spring MVC表单实例
  2. CentOS 6.x Radius
  3. Windows7系统下优化固态硬盘
  4. Codeforces div.2 B. The Child and Set
  5. CALayer与UIView的关系
  6. UISlider无法拖动进度条的问题解决
  7. 2016/3/20 数组定义 数组遍历 超全局数组 数组元素设置(in_array() 、array_reverse()、count()、array_unique()、unset()、array_values、array_merge、array_push) 列表实例
  8. VMnet1和VMnet8 未识别的网络的解决方法
  9. make的特殊之处
  10. id 查询