0
我做了两个功能,其中一个从左到右翻转图像,另一个从上到下翻转图像。但由于某种原因,当我加载图像时,图像没有任何事情发生。从左到右和从上到下翻转图像
这是从左向右翻转的代码。
void flip_horizontal(uint8_t array[],
unsigned int cols,
unsigned int rows)
{
unsigned int left = 0;
unsigned int right = cols;
for(int r = 0; r < rows; r++)
{
while(left != right && right > left)
{
int temp = array[r * cols+ left];
array[(r * cols) + left] = array[(r * cols) + cols - right];
array[(r * cols) + cols - right] = temp;
right++;
left++;
}
}
}
而这是从上到下翻转的代码。
void flip_vertical(uint8_t array[],
unsigned int cols,
unsigned int rows)
{
unsigned int top = 0;
unsigned int bottom = rows;
for(int r = 0; r < cols; r++)
{
while(top != bottom && bottom > top)
{
int temp = array[r * rows+ top];
array[(r * rows) + top] = array[(r * rows) + rows - bottom];
array[(r * rows) + rows - bottom] = temp;
bottom++;
top++;
}
}
}
的乐趣。如果这是你应该把它标记为这样的标签一门功课的问题。 – 2014-11-04 10:11:47
@JonCage,[没有这样的标签](http://meta.stackexchange.com/questions/147100/the-homework-tag-is-now-officially-deprecated) – 2014-11-04 10:15:54
公平点。让我纠正一下;如果这是家庭作业,它应该在标题中标记。 – 2014-11-04 10:23:37