Tag: 翻转

如何在C中旋转90度的图像

我一直试图将图像变成黑白图像,然后用C旋转90度,但我对编程很新,这就是我所要做的。 #include #include int main () { FILE* first; FILE* second; FILE* third; int counter; char c; int width, height, pixelmax, average; int pixelred, pixelgreen, pixelblue, black[300][300][3]; int i, j, timer=0; int k, f=0; first=fopen(“blackbuck.ppm”,”r”); second=fopen(“blacktrout.ppm”,”w”); 这会跳过前几行代码 for(counter=1;counter<3;counter++){ do{ c=getc(first); }while(c != '\n'); } fscanf(first,"%d%d", &width,&height); fscanf(first,"%d", &pixelmax); 在这个程序的这一部分,我通过取平均值将像素转为黑白,这是最容易的部分。 for(i=0, j=0; i<width;i++, timer++){ fscanf(first,"%d%d%d",&pixelred,&pixelgreen,&pixelblue); average=(pixelred+pixelgreen+pixelblue)/3; […]