int main(int argc,char **argv) { int grapherror; int scale=1,fullscreen=0; vmwVisual *virtual_1; char *filename,*outfile; vmwSVMWGraphState *graph_state; if (argc<3) { printf("\nUsage: %s pcx_file ppro_file\n\n",argv[0]); return -1; } filename=strdup(argv[1]); outfile=strdup(argv[2]); /* Setup Graphics */ if ( (graph_state=vmwSetupSVMWGraph(VMW_NULLTARGET, 320, 200, 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(320, 200))==NULL) { fprintf(stderr,"ERROR: Couldn't get RAM for virtual screen 1!\n"); return VMW_ERROR_MEM; } /* Load palette */ grapherror=vmwLoadPCX(0,0,virtual_1,1,1, filename, graph_state); vmwSavePicPacked(0,0,320,200,virtual_1, graph_state->palette_size, graph_state->actual_pal,outfile); return 0; }
int main(int argc, char **argv) { int result; /* parse command line args */ if (argc>1) { strncpy(label_prefix,argv[1],BUFSIZ); } /* read from stdin */ result=vmwLoadPCX(fileno(stdin)); if (result<0) { fprintf(stderr,"Error reading PCX from stdin\n"); exit(1); } return 0; }
int main(int argc, char **argv) { int result;//,x,y; // FILE *fff; //char filename[]="butterfinger.pcx"; /* read from stdin */ result=vmwLoadPCX(fileno(stdin)); if (result<0) { fprintf(stderr,"Error reading PCX from stdin\n"); exit(1); } // fff=fopen("input.bin","w"); //if (fff==NULL) exit(1); // fwrite(buffer,sizeof(unsigned int),buffer[0]*buffer[1]+2,stdout); return 0; }
int main(int argc, char **argv) { int xsize=0,ysize=0,type; unsigned char *in_framebuffer; unsigned char *out_framebuffer; char *filename; if (argc<2) { fprintf(stderr,"\nUsage: %s PCXFILE\n\n",argv[0]); exit(1); } filename=strdup(argv[1]); vmwGetPCXInfo(filename,&xsize,&ysize,&type); in_framebuffer=calloc(xsize*ysize,sizeof(unsigned char)); if (in_framebuffer==NULL) { fprintf(stderr,"Error allocating memory!\n"); return -1; } vmwLoadPCX(filename,in_framebuffer); out_framebuffer=calloc(8192,sizeof(unsigned char)); if (out_framebuffer==NULL) { fprintf(stderr,"Error allocating memory!\n"); return -1; } if ((ysize==160) || (ysize=192)) { /* HGR or HGR2 */ } else { fprintf(stderr,"Warning, possibly truncating due to ysize: %d\n",ysize); } if (xsize==140) { make_color_image(in_framebuffer,out_framebuffer,xsize,ysize); } else if (xsize==280) { make_bw_image(in_framebuffer,out_framebuffer,xsize,ysize); } else { fprintf(stderr,"Error! PCX file wrong xsize %d\n",xsize); } unsigned char header[4]; /* assume HGR page 1 */ int offset=8192; /* Last 8 bytes are ignored anyway; by not saving them we can fit */ /* in 33 disk sectors rather than 34 */ int file_size=8184; header[0]=offset&0xff; header[1]=(offset>>8)&0xff; header[2]=file_size&0xff; header[3]=(file_size>>8)&0xff; fwrite(header,sizeof(unsigned char),4,stdout); /* Don't need the last 8 bytes; makes it fit in one fewer disk sectors */ fwrite(out_framebuffer,sizeof(unsigned char),8184,stdout); free(out_framebuffer); free(in_framebuffer); return 0; }