将未压缩的bmp旋转90倍

时间:2013-10-24 13:32:41

标签: c bmp image-rotation

我需要旋转一个给定角度为90的倍数的bmp。我试图弄清楚如何实现这一点。有人可以指导我正确的方向来解决这个问题吗?

旋转角度是90的倍数可以是正的也可以是负的。它也应该接受角度0

感谢您提前的时间。

1 个答案:

答案 0 :(得分:1)

更好的方法:

struct bitmap
{
  int** array[3]; //RGB
  int N;
  int M;
};

void f(struct bitmap source, struct bitmap dest)
{ for(int i=0;i<source.N;i++)
  {
    for(int j=0;j<source.M;j++)
    {
      dest.array[j][source.N-i-1]=source.array[i][j];
    }
  }
  dest.N=array.M;
  dest.M=array.N;
}

这是一张照片 enter image description here

逆时针旋转你只改变

dest.result[source.M-j-1][i]=source.array[i][j];