#include "Helpers.h" #include static void PrintBitmapInitializer(Bitmap *bitmap,const char *name,const char *indent); static void PrintBitmapPixelArray(Bitmap *bitmap,const char *name); int main(int argc,const char **argv) { if(argc!=2) { fprintf(stderr,"Usage: %s name output.c\n",argv[0]); exit(1); } const char *name=argv[1]; Bitmap *bitmap=AllocateBitmapWithContentsOfPNGFileOrDie("-"); PrintBitmapPixelArray(bitmap,name); printf("const Bitmap %s=",name); PrintBitmapInitializer(bitmap,name,""); printf(";\n"); } static void PrintBitmapInitializer(Bitmap *bitmap,const char *name,const char *indent) { int w=bitmap->width; int h=bitmap->height; printf("{ %d,%d,BytesPerRowForWidth(%d),(Pixel *)%s_pixels }",w,h,h,name); // Thanks to gcc bug #37303, we can't use the below code which rolls // the pixel array into the initializer. /* bool transparent=IsPartialBitmapTransparent(bitmap,x,y,w,h); printf("{\n"); printf("%s\t%d,%d,BytesPerRowForWidth(%d),\n",indent,w,h,h); printf("%s\t(const Pixel[NumberOfPixelsForWidthAndHeight(%d,%d)]) {",indent,w,h); for(int y=0;ywidth; int h=bitmap->height; bool blended=IsBitmapBlended(bitmap); printf("static const Pixel %s_pixels[NumberOfPixelsForWidthAndHeight(%d,%d)]=\n",name,w,h); printf("{"); for(int y=0;y