MESSAGE
DATE | 2016-12-06 |
FROM | John Bowler
|
SUBJECT | Re: [Learn] [png-mng-implement] 4 byte length storage
|
From learn-bounces-at-nylxs.com Tue Dec 6 14:21:06 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 21A39161316; Tue, 6 Dec 2016 14:21:06 -0500 (EST) X-Original-To: learn-at-www.mrbrklyn.com Delivered-To: learn-at-www.mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 1000) id DDA7F161311; Tue, 6 Dec 2016 14:20:57 -0500 (EST) Resent-From: Ruben Safir Resent-Date: Tue, 6 Dec 2016 14:20:57 -0500 Resent-Message-ID: <20161206192057.GB29134-at-www.mrbrklyn.com> Resent-To: learn-at-mrbrklyn.com X-Original-To: ruben-at-mrbrklyn.com Delivered-To: ruben-at-mrbrklyn.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by mrbrklyn.com (Postfix) with ESMTP id F08FD161312 for ; Tue, 6 Dec 2016 12:04:15 -0500 (EST) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cEJ7T-0008PQ-Oe; Tue, 06 Dec 2016 17:01:31 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cEJ7S-0008PJ-Al for png-mng-implement-at-lists.sourceforge.net; Tue, 06 Dec 2016 17:01:30 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.161.179 as permitted sender) client-ip=209.85.161.179; envelope-from=john.cunningham.bowler-at-gmail.com; helo=mail-yw0-f179.google.com; Received: from mail-yw0-f179.google.com ([209.85.161.179]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1cEJ7L-0005Uq-8z for png-mng-implement-at-lists.sourceforge.net; Tue, 06 Dec 2016 17:01:30 +0000 Received: by mail-yw0-f179.google.com with SMTP id a10so277859912ywa.3 for ; Tue, 06 Dec 2016 09:01:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=CyykrDyHYszG7UWLXjyK53ncn0FvbujWNKGIj6jVxAY=; b=b5x9KlrCjezhQXGQ2j2dcx9w87scrim7MWiii5E204BxmsaE5iOkDRhfsSgOc7c6wn L7USML31tbYhEFi6H/O5NRh0rE9WKHOk5nRa9VOD0ShCeIH1syeBTYZYvoro/0QaBfnP hc9ltNpORHqcdRwKC+odE/BCWKJomaPuwkv06rbk/K5s0gDJuYBRCmovZL4MC1izO7Xs SxcucQQPWFehZFfvegH0MxSP2T7/EozwN+nIH/PX4sPkTCruxFxojglS+UJbruv21nM4 jllGtttV2JEI6u+KD7byXJVIhRp7sh1wbBcer1lIwP4SB8J7Xn7ctkFGHIb2/n0ukNl+ dnxQ== X-Gm-Message-State: AKaTC02Mm2QQWkwmqmTFNpfSqK7KEGyK/HowWHl0XQsKN7h9czUoVAQGYcPnTo3VMHsRk7HkPpuR8HdI1BlIvQ== X-Received: by 10.13.221.138 with SMTP id g132mr58901761ywe.351.1481043674247; Tue, 06 Dec 2016 09:01:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.46.66 with HTTP; Tue, 6 Dec 2016 09:01:13 -0800 (PST) In-Reply-To: <17705460-c78b-6310-807f-417193dc4f6b-at-mrbrklyn.com> References: <17705460-c78b-6310-807f-417193dc4f6b-at-mrbrklyn.com> From: John Bowler Date: Tue, 6 Dec 2016 09:01:13 -0800 Message-ID: To: "PNG/MNG implementation discussion list" X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.161.179 listed in list.dnswl.org] -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (john.cunningham.bowler[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1cEJ7L-0005Uq-8z X-BeenThere: png-mng-implement-at-lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Subject: Re: [Learn] [png-mng-implement] 4 byte length storage X-BeenThere: learn-at-nylxs.com Reply-To: PNG/MNG implementation discussion list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
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 _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|