979 if (fname.size()<4 || fname.compare(fname.size()-4,4,
".png")==0)
982 cout <<
"Writing PNG '" << fname <<
"'" << endl;
988 FILE *fd = fopen(fname.c_str(),
"w");
991 cout <<
"Warning: Cannot open file for writing." << endl;
998 png_structp fPng = png_create_write_struct(PNG_LIBPNG_VER_STRING,
1003 cout <<
"Warning: Unable to create PNG structure" << endl;
1009 png_infop fInfo = png_create_info_struct(fPng);
1013 cout <<
"Warning: Unable to create PNG info structure" << endl;
1014 png_destroy_write_struct (&fPng, NULL);
1020 fInfo->height = 576;
1021 fInfo->bit_depth = 8;
1022 fInfo->color_type = PNG_COLOR_TYPE_RGB;
1028 if (setjmp(fPng->jmpbuf))
1030 cout <<
"longjmp Warning: PNG encounterd an error!" << endl;
1031 png_destroy_write_struct (&fPng, &fInfo);
1039 png_init_io(fPng, fd);
1046 png_write_info(fPng, fInfo);
1048 png_byte buf[768*576*3];
1051 const byte *g = gbuf;
1052 const byte *c = cbuf;
1055 while (d<buf+768*576*3)
1059 *d++ = ((*c>>4)&0x3)*85;
1060 *d++ = ((*c>>2)&0x3)*85;
1061 *d++ = ((*c++ )&0x3)*85;
1076 for (
unsigned int y=0; y<768*576*3; y+=768*3)
1077 png_write_row (fPng, buf+y);
1082 png_write_end (fPng, fInfo);
1087 png_destroy_write_struct (&fPng, &fInfo);
1091 cout <<
"Sorry, no png support compiled into tpoint." << endl;