/* Views paintpro files */ /* Also will re-save them */ #include #include /* for strdup */ #include /* for usleep() */ #include /* for exit() */ #include "svmwgraph.h" int main(int argc,char **argv) { int grapherror; int scale=1,fullscreen=0; vmwVisual *virtual_1; // vmwPaintProHeader *ppro_header; // char *filename; char ch=0; // char save_string[BUFSIZ]; char *extension,*temp_string1,*temp_string2; int xsize,ysize,type; int is_pcx=0,target=VMW_SDLTARGET; int whichfile; vmwSVMWGraphState *graph_state; if (argc<2) { printf("\nUsage: %s filename ...\n\n",argv[0]); return -1; } whichfile=1; while(whichfileppro_string,"PAINTPRO",8)) { printf("ERROR! Not in paintpro format!\n"); return 0; } if (strncmp(ppro_header->version,"V6.",3)) { printf("ERROR! Not a version 6.x file!\n"); return 0; } printf(" + Verified PaintPro v%c.%c file.\n",ppro_header->version[1], ppro_header->version[3]); printf(" + Picture is %ix%i with %i colors.\n", ppro_header->xsize,ppro_header->ysize,ppro_header->num_colors); if (ppro_header->version[3]=='0') { /* broken ppro 6.0 files sometimes were saved as 319x199 */ ppro_header->xsize=320; ppro_header->ysize=205; } xsize=ppro_header->xsize; ysize=ppro_header->ysize; } #endif /* Setup Graphics */ if ( (graph_state=vmwSetupSVMWGraph(target, xsize, ysize, 0,scale,fullscreen,1))==NULL) { fprintf(stderr,"ERROR: Couldn't get display set up properly.\n"); return VMW_ERROR_DISPLAY; } /* Allocate Virtual screen */ if ((virtual_1=vmwSetupVisual(xsize,ysize))==NULL) { fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 1!\n"); return VMW_ERROR_MEM; } if (is_pcx) { grapherror=vmwLoadPCX(0,0,virtual_1,1,1,argv[whichfile],graph_state); } else { /* Paintpro */ grapherror=vmwLoadPicPacked(0,0,virtual_1,1,1, argv[whichfile], graph_state); } vmwBlitMemToDisplay(graph_state,virtual_1); while ( (ch=vmwGetInput())==0) usleep(100); if ((ch=='Q') || (ch=='q') || (ch==VMW_ESCAPE)) break; whichfile++; if (whichfile>=argc) whichfile=1; } vmwCloseGraphics(); return 0; }