#include <stdio.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;

// Open input file
fpin = fopen("C:/barbara512.raw", "rb");
if (fpin == NULL)
{
    printf("Failed to open input file.\n");
    return 1;
}

// Read input image
for (i = 0; i < HEIGHT; i++)
{
    for (j = 0; j < WIDTH; j++)
    {
        fread(&srcimg[i][j], 1, 1, fpin);
    }
}

// Close input file
fclose(fpin);

// Perform vertical flip
for (i = 0; i < HEIGHT; i++)
{
    for (j = 0; j < WIDTH; j++)
    {
        newimg[i][j] = srcimg[HEIGHT - 1 - i][j];
    }
}

// Open output file
fpout = fopen("C:/barbara512_flipped.raw", "wb");
if (fpout == NULL)
{
    printf("Failed to open output file.\n");
    return 1;
}

// Write flipped image to output file
for (i = 0; i < HEIGHT; i++)
{
    for (j = 0; j < WIDTH; j++)
    {
        fwrite(&newimg[i][j], 1, 1, fpout);
    }
}

// Close output file
fclose(fpout);

return 0;
#define HEIGHT 256#define WIDTH 256int main FILE fpin; FILE fpout; FILE fp1; unsigned char srcimgHEIGHTWIDTH; unsigned char newimgHEIGHT1WIDTH1; int j i; fpin = fopenCbarbara512ra

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

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