#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;

}

C语言图像垂直翻转程序代码示例 -  图像处理

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

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