#include\x20<stdio.h>

#define\x20HEIGHT\x20256 #define\x20WIDTH\x20256

int\x20main() { \x20\x20FILE*\x20fpin; \x20\x20FILE*\x20fpout; \x20\x20unsigned\x20char\x20srcimg[HEIGHT][WIDTH]; \x20\x20unsigned\x20char\x20newimg[HEIGHT][WIDTH]; \x20\x20int\x20i, j;

\x20\x20//\x20Open\x20input\x20file \x20\x20fpin\x20=\x20fopen("C:/barbara512.raw", "rb"); \x20\x20if\x20(fpin\x20==\x20NULL) \x20\x20{ \x20\x20\x20\x20printf("Failed\x20to\x20open\x20input\x20file.\n"); \x20\x20\x20\x20return\x201; \x20\x20}

\x20\x20//\x20Read\x20input\x20image \x20\x20for\x20(i\x20=\x200; i\x20<\x20HEIGHT; i++) \x20\x20{ \x20\x20\x20\x20for\x20(j\x20=\x200; j\x20<\x20WIDTH; j++) \x20\x20\x20\x20{ \x20\x20\x20\x20\x20\x20fread(&srcimg[i][j], 1, 1, fpin); \x20\x20\x20\x20} \x20\x20}

\x20\x20//\x20Close\x20input\x20file \x20\x20fclose(fpin);

\x20\x20//\x20Perform\x20vertical\x20flip \x20\x20for\x20(i\x20=\x200; i\x20<\x20HEIGHT; i++) \x20\x20{ \x20\x20\x20\x20for\x20(j\x20=\x200; j\x20<\x20WIDTH; j++) \x20\x20\x20\x20{ \x20\x20\x20\x20\x20\x20newimg[i][j]\x20=\x20srcimg[HEIGHT\x20-\x201\x20-\x20i][j]; \x20\x20\x20\x20} \x20\x20}

\x20\x20//\x20Open\x20output\x20file \x20\x20fpout\x20=\x20fopen("C:/barbara512_flipped.raw", "wb"); \x20\x20if\x20(fpout\x20==\x20NULL) \x20\x20{ \x20\x20\x20\x20printf("Failed\x20to\x20open\x20output\x20file.\n"); \x20\x20\x20\x20return\x201; \x20\x20}

\x20\x20//\x20Write\x20flipped\x20image\x20to\x20output\x20file \x20\x20for\x20(i\x20=\x200; i\x20<\x20HEIGHT; i++) \x20\x20{ \x20\x20\x20\x20for\x20(j\x20=\x200; j\x20<\x20WIDTH; j++) \x20\x20\x20\x20{ \x20\x20\x20\x20\x20\x20fwrite(&newimg[i][j], 1, 1, fpout); \x20\x20\x20\x20} \x20\x20}

\x20\x20//\x20Close\x20output\x20file \x20\x20fclose(fpout);

\x20\x20return\x200;


原文地址: https://www.cveoy.top/t/topic/pwev 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录