> Но вроде бы какой-то алго выстроился у меня.на
https://github.com/hankking11/ImageManip/blob/master/ppm.c
первае что в бошку пришло, и что важно - это работает и есть аптимизираванныи реализации хоть под канкретный камень
//This function takes in a ppmPic structure
//and returns a ppmPic structure representing an
//inverted version of the original picture (inverts the colors)
ppmPic *
invertppmPic(ppmPic *a)
{
int i;
int j; //j is the row number
for (j = 0; j < a->rows; j++)
{ //This for loop inverts each row one at a time
i = 0;
//i is the column number
while(i < a->cols)
{ //This while loop inverts one row (row j)
a->pixels[j][i].red = a->colors - a->pixels[j][i].red;
a->pixels[j][i].green = a->colors - a->pixels[j][i].green;
a->pixels[j][i].blue = a->colors - a->pixels[j][i].blue;
i++;
}
}
return a;
}
//This function takes in a ppmPic structure
//and returns a ppmPic structure representing a
//horizontally flipped version of the original picture
ppmPic *
swapppmPic(ppmPic *a)
{
int i;
Pixel temp;
int j; //j is the row number
for (j = 0; j < a->rows; j++)
{ //This for loop swaps each row, one at a time
i = 0; //i is the column number
while(i < a->cols / 2) //integer division is used, so the middle row is not
{ //swapped with itself if there's an odd number of cols
temp = a->pixels[j][i]; //This while loop swaps one row (row j)
a->pixels[j][i] = a->pixels[j][a->cols - i - 1];
a->pixels[j][a->cols - i - 1] = temp;
i++;
}
}
return a;
}
//This function takes in a ppmPic structure
//and returns a ppmPic structure representing an
//upside-down version of the original picture
ppmPic *
flipppmPic(ppmPic *a)
{
int i; // integer division is used, so the middle row
Pixel temp; //is not swapped with itself if there is an
int j; //odd number of rows. (in the for loop
for (j = 0; j < a->rows / 2; j++) //condition)
{ //This for loop switches the top half to the bottom half
i = 0; //i is the column number
while(i < a->cols)
{ //This while loop switches an upper half row with
temp = a->pixels[j][i]; //a corresponding lower half row
a->pixels[j][i] = a->pixels[a->rows - 1 - j][i];
a->pixels[a->rows - 1 - j][i] = temp;
i++;
}
}
return a;
}