#include <stdio.h>
#include <stdlib.h>
#define WIDTH 63
#define HEIGHT 63
void main()
{
unsigned char red;
unsigned char green;
unsigned char blue;
int colorVal;
int i, j;
FILE* source = fopen("image.raw", "rb");
FILE* target = fopen("image.txt", "w");
for(i=0 ; i<HEIGHT ; i++)
{
for(j=0 ; j<WIDTH ; j++)
{
red = fgetc(source);
green = fgetc(source);
blue = fgetc(source);
colorVal = red + green*256 + blue*65536;
fprintf(target, "%d", colorVal);
fprintf(target, "\n");
}
}
fclose(source);
fclose(target);
} |