MESSAGE
DATE | 2016-12-06 |
FROM | John Bowler
|
SUBJECT | Re: [Hangout-NYLXS] [png-mng-implement] 4 byte length storage
|
These days almost all computer operating systems (maybe all) present files as a sequence of numerical values each of which is in the range 0 to 255 ("bytes"). This is also the universal interchange format for files that are transferred between systems using networks.
A PNG is a file so the only thing in it is a (single) sequence of such numbers; this is all that can be read from any file.
The ISO/IEC PNG specification, here:
http://www.libpng.org/pub/png/spec/iso/index-object.html
describes how this stream of bytes is structured in section (5) "Datastream structure", then it describes how this structure is ENCODED in the stream in section (7) "Encoding the PNG image as a PNG datastream." In particular in this case 7.1 explains how an integral value bigger than 255 is encoded.
The encoding (section 7) has to be reversed to obtain the integral values described in section 5 and elsewhere. Many operating systems provide "serialization" primitives for doing this, but since the encoding PNG uses is OS independent, it is necessary to do it in a operating system independent fashion. The built in C++ << operators are an example of such a thing; a particular serialization that does not match the PNG one (in this case.)
libpng exports serialization primitives (e.g. get_uint_32 in this case) that can be used. They take a buffer (array of bytes, as you described it) with the original bytes read from the stream. Other approaches are possible; in C++ you might choose to define a stream class for a PNG with overloaded << operators that do the correct decoding.
John Bowler
------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today.http://sdm.link/xeonphi _______________________________________________ png-mng-implement mailing list png-mng-implement-at-lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/png-mng-implement _______________________________________________ hangout mailing list hangout-at-nylxs.com http://www.nylxs.com/
|
|