#include stdlibh#include stdioh#include stringh#define HEIGHT 256#define WIDTH 256int main FILE fpin; FILE fpout; FILE fp1; unsigned char srcimgHEIGHTWIDTH; unsigned char newimgHEIGHT1W
#include <stdlib.h> #include <stdio.h> #include <string.h>
#define HEIGHT 256 #define WIDTH 256
int main() { FILE* fpin; FILE* fpout; unsigned char srcimg[HEIGHT][WIDTH]; unsigned char newimg[HEIGHT][WIDTH]; int i, j;
fpin = fopen("C:/barbara512.raw", "rb");
if (fpin == NULL)
{
printf("Failed to open input file.\n");
return 1;
}
for (i = 0; i < HEIGHT; i++)
{
fread(srcimg[i], 1, WIDTH, fpin);
}
fclose(fpin);
for (i = 0; i < HEIGHT; i++)
{
for (j = 0; j < WIDTH; j++)
{
newimg[i][j] = srcimg[HEIGHT - 1 - i][j];
}
}
fpout = fopen("C:/tmp/lena256.raw", "wb");
if (fpout == NULL)
{
printf("Failed to open output file.\n");
return 1;
}
for (i = 0; i < HEIGHT; i++)
{
fwrite(newimg[i], 1, WIDTH, fpout);
}
fclose(fpout);
return 0;
原文地址: https://www.cveoy.top/t/topic/hM6S 著作权归作者所有。请勿转载和采集!