--- ansi2gif.c.orig 2008-01-23 03:52:28.000000000 -0800 +++ ansi2gif.c 2008-01-23 03:46:30.000000000 -0800 @@ -335,7 +335,7 @@ static void gif_the_text(int animate,int blink, FILE *in_f,FILE *out_f, - int time_delay,int x_size,int y_size, + int time_delay,int x_size,int y_size, int y_auto, int output_type) { FILE *animate_f=NULL; @@ -621,82 +621,94 @@ x_position=x_position%x_size; y_position++; } - if (y_position>y_size) { - emergency_exit=1; - printf("Error! Scrolled past maximum y_size of %i!\n\n",y_size); - } - } - } - if (!(animate||blink)) { /* If not animating, draw the final picture */ - - if (output_type==OUTPUT_EPS) { - display_eps(out_f,output_type,x_size,y_size); - } - else { - display_gd(out_f,output_type,x_size,y_size); +// if (y_position>y_size) { +// emergency_exit=1; +// printf("Error! Scrolled past maximum y_size of %i!\n\n",y_size); +// } } } + if( 1 == y_auto ) + { + y_auto = 0; + y_size = y_position; + printf( "y_size: %d\n", y_size ); + rewind( in_f ); + rewind( out_f ); + gif_the_text( animate, blink, in_f, out_f, time_delay, x_size, y_size, y_auto, output_type ); + } + else + { + if (!(animate||blink)) { /* If not animating, draw the final picture */ + + if (output_type==OUTPUT_EPS) { + display_eps(out_f,output_type,x_size,y_size); + } + else { + display_gd(out_f,output_type,x_size,y_size); + } + } - if ((!animate) && (blink)) { /* If blinking... */ + + if ((!animate) && (blink)) { /* If blinking... */ + + for(i=0;i<2;i++) { + for(y=0;yfont_data[(screen[x+(y*x_size)]*16)+yy])) & + (128>>xx) ) { + if ((attributes[x+(y*x_size)]&0x80)) { + if (i) { + gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[attributes[x+(y*x_size)]&0x0f]); + } + else { + gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[(attributes[x+(y*x_size)]&0x70)>>4]); + } + + } + else { + gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[attributes[x+(y*x_size)]&0x0f]); + } + } + else { + gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[(attributes[x+(y*x_size)]&0x70)>>4]); + } + } + } + } + } + + sprintf(temp_file_name,"/tmp/ansi2gif_%i.gif",getpid()); + animate_f=fopen(temp_file_name,"wb"); + gdImageGif(im, animate_f); + fclose(animate_f); + animate_gif(out_f,temp_file_name,(1-i),0,0,time_delay,1); + } + fputc(';',out_f); + } - for(i=0;i<2;i++) { - for(y=0;yfont_data[(screen[x+(y*x_size)]*16)+yy])) & - (128>>xx) ) { - if ((attributes[x+(y*x_size)]&0x80)) { - if (i) { - gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[attributes[x+(y*x_size)]&0x0f]); - } - else { - gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[(attributes[x+(y*x_size)]&0x70)>>4]); - } - - } - else { - gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[attributes[x+(y*x_size)]&0x0f]); - } - } - else { - gdImageSetPixel(im,(x*8)+xx,(y*16)+yy,colorF[(attributes[x+(y*x_size)]&0x70)>>4]); - } - } - } - } - } - - sprintf(temp_file_name,"/tmp/ansi2gif_%i.gif",getpid()); - animate_f=fopen(temp_file_name,"wb"); - gdImageGif(im, animate_f); - fclose(animate_f); - animate_gif(out_f,temp_file_name,(1-i),0,0,time_delay,1); + if (animate) { + fputc(';', out_f); /* End of Gif file */ + } + if ((backtrack) && !(animate)) { + // printf("Warning! The cursor moved backwards and animated output was not selected.\n" + // " For proper output, you might want to try again with --animate\n\n"); } - fputc(';',out_f); - } - - if (animate) { - fputc(';', out_f); /* End of Gif file */ - } - if ((backtrack) && !(animate)) { - printf("Warning! The cursor moved backwards and animated output was not selected.\n" - " For proper output, you might want to try again with --animate\n\n"); - } - if ((use_blink)&&(!blink)) { - printf("Warning! A blinking color code was used. To display blinking ansis you\n" - " to run with the --blink option to create an animated gif.\n\n"); - } - if (output_type==OUTPUT_EPS) { - finish_eps(out_f); - } - else { - finish_gd(out_f); - } - - unlink(temp_file_name); - + if ((use_blink)&&(!blink)) { + printf("Warning! A blinking color code was used. To display blinking ansis you\n" + " to run with the --blink option to create an animated gif.\n\n"); + } + if (output_type==OUTPUT_EPS) { + finish_eps(out_f); + } + else { + finish_gd(out_f); + } + + unlink(temp_file_name); + } } @@ -804,6 +816,7 @@ int time_delay=DEFAULT_TIMEDELAY; int x_size=DEFAULT_XSIZE,y_size=DEFAULT_YSIZE; + int y_auto = 0; int animate=0,blink=0; char *font_name=NULL,*input_name=NULL,*output_name=NULL; char *endptr; @@ -871,17 +884,20 @@ exit(9); } break; - case 'y': if (!strcmp(optarg,"auto")) { - printf("\nError! Automatic sizing is not " - "implemented yet. Sorry.\n\n"); - exit(12); - } - y_size=strtol(optarg,&endptr,10); - if ( endptr == optarg ) { - printf("\nError! \"%s\" is not a valid y size.\n\n", - optarg); - exit(9); - } + case 'y': if (!strcmp(optarg,"auto")) + { + y_auto = 1; + y_size = 1000; + } + else + { + y_size=strtol(optarg,&endptr,10); + if ( endptr == optarg ) + { + printf("\nError! \"%s\" is not a valid y size.\n\n", optarg); + exit(9); + } + } break; default : printf("\nError! Bad command line option!\n\n"); exit(5); @@ -934,7 +950,7 @@ } gif_the_text(animate,blink,input_f,output_f, - time_delay,x_size,y_size,output_type); + time_delay,x_size,y_size,y_auto,output_type); fclose(input_f); return 0;