// NOTE: This code doesn't quite work right. I once wrote a version that wrote jpegs // using library functions which worked well, but I can no longer find the code. If // anyone ever actually shows interest in display of results from mc, hey, let me know - // I'll write up a neat graphics generator that handles time-progression output and // various display options (such as assigning different content display to each of R, G, // and B). Just email me at meme@daughtersoftiresias.org. #include #include #include #define X_RES_OUT 1000 #define Y_RES_OUT 1000 const unsigned char ON_BIT[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; const unsigned char OFF_BIT[] = { 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F }; typedef struct BitmapFileHeader { char type1; char type2; unsigned long size; unsigned short reserved1; unsigned short reserved2; unsigned long offBits; } BitmapFileHeader; typedef struct BitmapInfoHeader { unsigned long size; long width; long height; short planes; short bitCount; unsigned long compression; unsigned long sizeImage; long xPelsPerMeter; long yPelsPerMeter; unsigned long clrUsed; unsigned long clrImportant; } BitmapInfoHeader; typedef struct BitmapPaletteEntry { unsigned char r; unsigned char g; unsigned char b; unsigned char unused; } BitmapPaletteEntry; typedef struct BitmapPaletteHeader { BitmapPaletteEntry pal[256]; } BitmapPaletteHeader; int main(int argc, char** argv) { gzFile* gfp; FILE* fp; unsigned long i,x,y,x2,y2; unsigned char* world; unsigned long long* world2; unsigned long long* counts; float version; unsigned long x_res, y_res, x_resB; unsigned long long steps; BitmapFileHeader bf; BitmapInfoHeader bi; BitmapPaletteHeader bp; if (argc!=3) { printf("Error: Requires the filenames of the .sav file and the .bmp file\n"); return 1; } if (!(gfp=gzopen(argv[1],"r"))) { printf("Error: cannot read input file.\n"); return 2; } gzread(gfp,&version,4); gzread(gfp,&x_res,4); gzread(gfp,&y_res,4); gzread(gfp,&steps,8); x_resB=x_res/8; printf("Reading %s: Ver=%2.1f, X=%d, Y=%d, Steps=%d\n",argv[1],version,x_res,y_res,steps); world=malloc(x_res*y_res*sizeof(unsigned char)); world2=malloc(X_RES_OUT * Y_RES_OUT * sizeof(unsigned long long)); counts=malloc(X_RES_OUT * Y_RES_OUT * sizeof(unsigned long long)); for (y=0; y0); counts[x2+y2*X_RES_OUT]++; } } for (y=0; y