gr-utils: minor fixes to png2gr

This commit is contained in:
Vince Weaver 2017-05-03 12:31:59 -04:00
parent 2587d829bf
commit d719c673fa

View File

@ -15,11 +15,13 @@
int main(int argc, char **argv) {
int image[40][40];
int image[40][48];
int x,y;
FILE *infile,*outfile;
int debug=0;
memset(image,0,sizeof(int)*40*48);
if (argc<3) {
fprintf(stderr,"Usage:\t%s INFILE OUTFILE\n\n",argv[0]);
exit(-1);
@ -32,12 +34,12 @@ int main(int argc, char **argv) {
}
int width, height;
png_byte color_type;
// png_byte color_type;
png_byte bit_depth;
png_structp png_ptr;
png_infop info_ptr;
int number_of_passes;
// int number_of_passes;
png_bytep * row_pointers;
unsigned char header[8];
@ -76,14 +78,14 @@ int main(int argc, char **argv) {
width = png_get_image_width(png_ptr, info_ptr);
height = png_get_image_height(png_ptr, info_ptr);
color_type = png_get_color_type(png_ptr, info_ptr);
// color_type = png_get_color_type(png_ptr, info_ptr);
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
if (debug) {
printf("PNG: width=%d height=%d depth=%d\n",width,height,bit_depth);
}
number_of_passes = png_set_interlace_handling(png_ptr);
// number_of_passes = png_set_interlace_handling(png_ptr);
png_read_update_info(png_ptr, info_ptr);
row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
@ -178,6 +180,9 @@ int main(int argc, char **argv) {
if (x>0x3f8) break;
enough++;
if (enough>119) {
/* screen hole */
/* We should never BLOAD this image */
/* as we can corrupt important state here */
fputc(0,outfile);
fputc(0,outfile);
fputc(0,outfile);