From: Sujeet A. <SA...@ra...> - 2006-11-28 20:54:32
|
After setting up my custom read function, I discovered that it was longjmp'ing away at the same point every time. I suppose this could be a problem with the file, however, this is simply the pngtest.png provided with libpng. Here is my custom read fn: void my_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { PNGTK* pngtk = (PNGTK*) png_get_io_ptr(png_ptr); //simple struct with a pointer to the buffer with my png, // offset from the original start of the buffer, and its size NKDbgPrintfW(L"[Sujeet, buf=%p; dwPos=%u; dwSize=%u!]\r\n",pngtk->buf, pngtk->dwPos, pngtk->dwSize); //some serial output calls NKDbgPrintfW(L"[Sujeet, png_ptr=%p; data=%p; length=%i!]\r\n",png_ptr, data, length); memcpy(data, pngtk->buf, length); pngtk->buf += 8; pngtk->dwPos += 8; NKDbgPrintfW(L"[Sujeet, I copied %i bytes from pngtk->buf to data!]\r\n",length); return; } >From the output, I see that it longjmp to the code where I say "we got hosed", and it always does so after 16bytes. [Sujeet, buf=100010; dwPos=0; dwSize=8574!] [Sujeet, png_ptr=4DDF0; data=5EDE0; length=8!] [Sujeet, I copied 8 bytes from pngtk->buf to data!] [Sujeet, buf=100018; dwPos=8; dwSize=8574!] [Sujeet, png_ptr=4DDF0; data=160AA1B0; length=4!] [Sujeet, I copied 4 bytes from pngtk->buf to data!] [Sujeet, buf=100020; dwPos=16; dwSize=8574!] [Sujeet, png_ptr=4DDF0; data=4DF0C; length=4!] [Sujeet, I copied 4 bytes from pngtk->buf to data!] [Sujeet, we got hosed!] Any ideas on what's going on here? Would it be worthwhile to use the chunk callbacks? Sujeet png...@li... wrote on 11/28/2006 10:10:33 AM: > > It turns out libpng was having problems reading the image: I guess > the longjmp/setjmp stuff gets messed up while debugging. Currently, > I am trying to write my own read fn's for libpng to use, but I would > much rather just use the FILE* but do not know how to debug this, as > it does happen consistently. Any ideas? > > Sujeet > > png...@li... wrote on 11/21/2006 > 01:28:36 PM: > > > > > In my call to png_read_png, the function simply hangs. I thought > > that if hit a bad chunk or something like that it would longjmp back > > and return; out of my function. Here is my setup: > > > > > > // the contents of the file named szSaveFileName have been verified > > as a PNG already by png_sig_cmp, while it was sitting in a buffer, > > before being written out. > > > > if ((fpPng = fopen(szSaveFileName, "rb")) == NULL ) > > return; > > > > png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, > > NULL, NULL, NULL); // I thought using NULL for the error fn's could > > have been why, but the sample > > > > // provided by greg readpng.c creates it this way, as well. > > > > if (!png_ptr) > > return; > > > > png_infop info_ptr = png_create_info_struct(png_ptr); > > if (!info_ptr) > > { > > png_destroy_read_struct(&png_ptr, (png_infopp)NULL, > (png_infopp)NULL); > > return; > > } > > > > if (setjmp(png_jmpbuf(png_ptr))) > > { > > png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); > > fclose(fpPng); > > return; > > } > > > > // all of these statements complete successfully. > > png_init_io(png_ptr, fpPng); > > > > // while debugging, upon execution of this next statement, the > > debugger remains in [run] with nothing happening. no statements > > after this are executed > > png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, png_voidp_NULL); > > > > Any help is appreciated. > > > > Sujeet > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share your > > opinions on IT & business topics through brief surveys - and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > png-mng-implement mailing list > > png...@li... > > https://lists.sourceforge.net/lists/listinfo/png-mng-implement > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > png-mng-implement mailing list > png...@li... > https://lists.sourceforge.net/lists/listinfo/png-mng-implement |