C语言之图像旋转
2024-08-30 18:34:23
最近用到了图像向左或者向右旋转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);
}
}
}
最新文章
- java socket传送一个结构体给用C++编写的服务器解析的问题
- Json.net对于导航属性的处理(解决对象循环引用)
- 【转】drupal7请求异常,执行时间过长的解决方法
- 插入中文错误ERROR 1406 (22001): Data too long for column &#39;name&#39; at row 1
- 转!数据库连接池概念、种类、配置(DBCP\C3P0\JndI与Tomact配置连接池)
- Android Calendar获取年月日时分秒毫秒
- Atom编辑器入门到精通(四) Atom使用进阶
- leetcode面试准备:Multiply Strings
- redundant 行记录格式
- 利用USearch去除嵌合体(chimeras)
- BZOJ 2806: [Ctsc2012]Cheat [广义后缀自动机 单调队列优化DP 二分]
- same tree(判断两颗二叉树是否相等)
- WPF防止界面卡死并显示加载中效果
- Brute-forced Euclid Distance Transform
- Dubbo 服务集群容错配置
- go微服务框架go-micro深度学习(四) rpc方法调用过程详解
- unity3d射线控制移动
- nginx封ip,禁用IP段的设置说明
- django数据库操作-增删改查-多对多关系以及一对多(外键)关系
- atitit.spring hibernate的事务机制 spring不能保存对象的解决
热门文章
- Spring MVC表单实例
- CentOS 6.x Radius
- Windows7系统下优化固态硬盘
- Codeforces div.2 B. The Child and Set
- CALayer与UIView的关系
- UISlider无法拖动进度条的问题解决
- 2016/3/20 数组定义 数组遍历 超全局数组 数组元素设置(in_array() 、array_reverse()、count()、array_unique()、unset()、array_values、array_merge、array_push) 列表实例
- VMnet1和VMnet8 未识别的网络的解决方法
- make的特殊之处
- id 查询