read PPM file and store it in an array; coded with C
问题 I need to read a PPM file and store it in an array written in C. Can anybody help me out doing this? Thanks a lot. 回答1: The following code shows how to read, change the pixel colour and write an image in PPM format. I hope it helps. #include<stdio.h> #include<stdlib.h> typedef struct { unsigned char red,green,blue; } PPMPixel; typedef struct { int x, y; PPMPixel *data; } PPMImage; #define CREATOR "RPFELGUEIRAS" #define RGB_COMPONENT_COLOR 255 static PPMImage *readPPM(const char *filename) {