¿Повернуть на 90 градусов в минуту в c? - PullRequest
0 голосов
/ 24 сентября 2018

Я не очень хорош в c, я застрял в этой проблеме в течение нескольких дней, я нашел этот метод в Интернете, и я ищу, чтобы изменить его, но он не работает

это код, который я изменяю

   int rotate(PIXEL* original, int rows, int cols, int rotation,
   PIXEL** new, int* newrows, int* newcols)
   {
   int c,r;//counters for rows and columns
   *newrows = cols;
   *newcols = rows;
   //allocating space for the new rotated image
  *new = (PIXEL*)malloc(rows*cols*sizeof(PIXEL));
  PIXEL *o;
  PIXEL *n;

   for(r = 0; r < rows; r++)
    {
        for(c = 0; c < cols; c++ )
        {
                n = (*new) + (c * rows) + (rows + r + 1 );
                o = ((original) + (r * cols) + c);
                *n = *o;
        }//end of for
      }//end of for 
   return 0;
 }

У меня есть структура типа BMP

 typedef struct BMP
 {
char bm[2];             //(2 Bytes) 
unsigned char header[54];
int tamano;             //(4 Bytes) 
int reservado;          //(4 Bytes) 
int offset;             //(4 Bytes) 
int tamanoMetadatos;    //(4 Bytes) 
int alto;               //(4 Bytes) 
int ancho;              //(4 Bytes) 
short int numPlanos;    //(2 Bytes) 
short int profColor;    //(2 Bytes) 
int tipoCompresion;     //(4 Bytes)
int tamEstruc;          //(4 Bytes) 
int pxmh;               //(4 Bytes) 
int pxmv;               //(4 Bytes) 
int colorUsa;           //(4 Bytes)  
int colorImp;           //(4 Bytes) 
unsigned char **pixel;  
long long int size_p;
}BMP;

, что я хочу сделать, это изменить метод так, чтобы сначала прочитатьфайл bmp, поверните на 90 градусов и сохраните в новом файле bmp

Если вы могли бы посоветовать мне, это было бы очень полезно, спасибо

...