RE: [Algorithms] PNG w/ no libs
Brought to you by:
vexxed72
From: Scott, J. <JS...@ra...> - 2000-09-06 21:14:11
|
zlib is easy once you grok it (isn't anything tho?) Its usage is completely obfuscated in libpng too. Basically, to decompress... z_stream zdata; memset(&zdata, 0, sizeof(z_stream)); inflateInit(&zdata); zdata.next_in = (byte *)compressed_data; zdata.avail_in = compressed_data_size; while(zdata.avail_in) { zdata.next_out = (byte *)uncompressed_dest; zdata.avail_out = number_of_bytes_you_want; inflate(&zdata, Z_SYNC_FLUSH); } inflateEnd(&zdata); So, for PNG, you'd decompress a byte for the filter type, then row bytes for the line of data, and repeat for the number of lines. Everything returns Z_OK normally, or Z_STREAM_END when you have decompressed all the data (normally when avail_in is 0). To compress, do the same, but deflate rather than inflate. I've no need to remind you gents to sprinkle liberal amounts of error checking in there =) Cheers John -----Original Message----- From: Bass, Garrett T. [mailto:gt...@ut...] I'm also interested in this information. Zlib breaks my noggin. -----Original Message----- I've read a lot here about loading png's with and without using the libraries (pnglib & zlib) both pros and cons. I was wondering if anyone had any sample code for just loading pngs. I've read through the src for both libraries and there's a LOT of stuff I can't get my head around. (most of which I think is for saving and such which I don't want) I can parse through the chunks and all but the zlib stuff for decoding each line is stumping me anyone out there that can give me a hand? Jeremy Bake RtroActiv RAMetal _______________________________________________ GDAlgorithms-list mailing list GDA...@li... http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list |