esempio di relazione sul png

Upload: fguagnano90

Post on 04-Jun-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Esempio Di Relazione Sul PNG

    1/37

    PNG: formato del file e compressione

    AbstractThis document describes PNG (Portable Network Graphics), an extensible file format for the lossless,portable, well-compressed storage of raster images. PNG proides a patent-free replacement for G!" andcan also replace man# common uses of T!"". !ndexed-color, gra#scale, and truecolor images are supported,

    plus an optional alpha channel. $ample depths range from % to %& bits.

    PNG is designed to work well in online iewing applications, such as the 'orld 'ide 'eb, so it is full#streamable with a progressie displa# option. PNG is robust, proiding both full file integrit# checking andsimple detection of common transmission errors. lso, PNG can store gamma and chromaticit# data forimproed color matching on heterogeneous platforms.

    This specification defines an !nternet edia T#pe image*png.

    IntroductionThe design goals for this !nternational $tandard were+

    a. Portabilit#+ encoding, decoding, and transmission should be software and hardware

    platform independent.b. ompleteness+ it should be possible to represent truecolour, indexed-colour, and

    gre#scale images, in each case with the option of transparenc#, colour spaceinformation, and ancillar# information such as textual comments.

    c. $erial encode and decode+ it should be possible for datastreams to be generatedseriall# and read seriall#, allowing the datastream format to be used for on-the-fl#generation and displa# of images across a serial communication channel.

    d. Progressie presentation+ it should be possible to transmit datastreams so that anapproximation of the whole image can be presented initiall#, and progressiel#enhanced as the datastream is receied.

    e. obustness to transmission errors+ it should be possible to detect datastreamtransmission errors reliabl#.

    f. osslessness+ filtering and compression should presere all information.

    g. Performance+ an# filtering, compression, and progressie image presentationshould be aimed at efficient decoding and presentation. "ast encoding is a lessimportant goal than fast decoding. /ecoding speed ma# be achieed at theexpense of encoding speed.

    h. ompression+ images should be compressed effectiel#, consistent with the otherdesign goals.

    i. $implicit#+ deelopers should be able to implement the standard easil#.

    j. !nterchangeabilit#+ an# standard-conforming PNG decoder shall be capable ofreading all conforming PNG datastreams.

    k. "lexibilit#+ future extensions and priate additions should be allowed for withoutcompromising the interchangeabilit# of standard PNG datastreams.

    l. "reedom from legal restrictions+ no algorithms should be used that are not freel#aailable.

    1 ScopeThis !nternational $tandard specifies a datastream and an associated file format, Portable Network Graphics(PNG, pronounced 0ping0), for a lossless, portable, compressed indiidual computer graphics image

    transmitted across the !nternet. !ndexed-colour, gre#scale, and truecolour images are supported, withoptional transparenc#. $ample depths range from % to %& bits. PNG is full# streamable with a progressiedispla# option. !t is robust, proiding both full file integrit# checking and simple detection of commontransmission errors. PNG can store gamma and chromaticit# data as well as a full ! colour profile for

  • 8/13/2019 Esempio Di Relazione Sul PNG

    2/37

    accurate colour matching on heterogenous platforms. This $tandard defines the !nternet edia t#pe0image*png0. The datastream and associated file format hae alue outside of the main design goal.

    3 Terms, definitions, and abbreviated terms3.1 Definitions"or the purposes of this !nternational $tandard the following definitions appl#.

    3.1.1 alphaa alue representing apixel'sdegree of opacit#. The more opa1ue a pixel, the more ithides the background against which the image is presented. 2ero alpha represents acompletel# transparent pixel, maximum alpha represents a completel# opa1ue pixel.3.1.2 alpha compactionan implicit representation of transparentpixels. !f eer# pixel with a specific colouror greyscalealue is full# transparent and all other pixels are full# opa1ue,

    the alphachannelma# be represented implicitl#.3.1.3 alpha separationseparating an alphachannelin which eer#pixelis full# opa1ue3 all alpha alues are themaximum alue. The fact that all pixels are full# opa1ue is represented implicitl#.3.1.4 alpha tableindexed table of alphasamplealues, which in an indexed-colourimage defines the alphasample alues of the reference image. The alpha table has the same number of entries asthepalette.3.1.5 ancillary chunkclass of chunkthat proides additional information. PNG decoder, without processing anancillar# chunk, can still produce a meaningful image, though not necessaril# the best

    possible image.3.1.6 bit depthfor indexed-colour images, the number of bits perpalette index. "or other images, thenumber of bits per samplein the image. This is the alue that appears in the IHDRchunk.

    3.1.7 byte4 bits3 also called an octet. The highest bit (alue %54) of a b#te is numbered bit 63 thelowest bit (alue %) is numbered bit 7.3.1.8 byte orderordering of bytesfor multi-b#te data alues within aPNG fileor PNG datastream. PNGuses network byte order.3.1.9 channel

    arra# of all per-pixelinformation of a particular kind within a reference image. There arefie kinds of information+ red, green, blue, greyscale, and alpha. "or example the alphachannel is the arra# of alpha alues within a reference image.3.1.10 chromaticity (!"#pair of aluesx,ythat precisel# specif# a colour, except for the brightness information.3.1.11 chunksection of a PNG datastream. 8ach chunk has a chunk t#pe. ost chunks also includedata. The format and meaning of the data within the chunk are determined b# the chunkt#pe. 8ach chunk is either a critical chunkor anancillary chunk.3.1.12 colour typealue denoting how colour and alphaare specified in the PNG image. olour t#pes aresums of the following alues+ % (paletteused), 5 (truecolourused), 9 (alpha used). Thepermitted alues of colour t#pe are 7, 5, :, 9, and &.3.1.13 composite ($erb#

    http://www.w3.org/TR/PNG/#3pixelhttp://www.w3.org/TR/PNG/#3pixelhttp://www.w3.org/TR/PNG/#3greyscalehttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3channelhttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3channelhttp://www.w3.org/TR/PNG/#3pixelhttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3samplehttp://www.w3.org/TR/PNG/#3indexedColourhttp://www.w3.org/TR/PNG/#3referenceImagehttp://www.w3.org/TR/PNG/#3palettehttp://www.w3.org/TR/PNG/#3chunkhttp://www.w3.org/TR/PNG/#3PNGdecoderhttp://www.w3.org/TR/PNG/#3indexedColourhttp://www.w3.org/TR/PNG/#3palettehttp://www.w3.org/TR/PNG/#3samplehttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#3chunkhttp://www.w3.org/TR/PNG/#3bytehttp://www.w3.org/TR/PNG/#3PNGfilehttp://www.w3.org/TR/PNG/#3PNGfilehttp://www.w3.org/TR/PNG/#3PNGdatastreamhttp://www.w3.org/TR/PNG/#3networkByteOrderhttp://www.w3.org/TR/PNG/#3pixelhttp://www.w3.org/TR/PNG/#3referenceImagehttp://www.w3.org/TR/PNG/#3greyscalehttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3PNGdatastreamhttp://www.w3.org/TR/PNG/#3criticalChunkhttp://www.w3.org/TR/PNG/#3ancillaryChunkhttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3PNGimagehttp://www.w3.org/TR/PNG/#3palettehttp://www.w3.org/TR/PNG/#3truecolourhttp://www.w3.org/TR/PNG/#3pixelhttp://www.w3.org/TR/PNG/#3greyscalehttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3channelhttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3channelhttp://www.w3.org/TR/PNG/#3pixelhttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3samplehttp://www.w3.org/TR/PNG/#3indexedColourhttp://www.w3.org/TR/PNG/#3referenceImagehttp://www.w3.org/TR/PNG/#3palettehttp://www.w3.org/TR/PNG/#3chunkhttp://www.w3.org/TR/PNG/#3PNGdecoderhttp://www.w3.org/TR/PNG/#3indexedColourhttp://www.w3.org/TR/PNG/#3palettehttp://www.w3.org/TR/PNG/#3samplehttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#3chunkhttp://www.w3.org/TR/PNG/#3bytehttp://www.w3.org/TR/PNG/#3PNGfilehttp://www.w3.org/TR/PNG/#3PNGdatastreamhttp://www.w3.org/TR/PNG/#3networkByteOrderhttp://www.w3.org/TR/PNG/#3pixelhttp://www.w3.org/TR/PNG/#3referenceImagehttp://www.w3.org/TR/PNG/#3greyscalehttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3PNGdatastreamhttp://www.w3.org/TR/PNG/#3criticalChunkhttp://www.w3.org/TR/PNG/#3ancillaryChunkhttp://www.w3.org/TR/PNG/#3alphahttp://www.w3.org/TR/PNG/#3PNGimagehttp://www.w3.org/TR/PNG/#3palettehttp://www.w3.org/TR/PNG/#3truecolourhttp://www.w3.org/TR/PNG/#3pixel
  • 8/13/2019 Esempio Di Relazione Sul PNG

    3/37

    to form an image b# merging a foreground image and a background image, usingtransparenc# information to determine where and to what extent the background should beisible. The foreground image is said to be 0composited against0 the background.3.1.14 critical chunkchunk that shall be understood and processed b# the decoder in order to produce a

    meaningful image from a PNG datastream.3.1.15 datastreamse1uence of bytes. This term is used rather than 0file0 to describe a b#te se1uence thatma# be onl# a portion of a file. !t is also used to emphasi;e that the se1uence of b#tesmight be generated and consumed 0on the fl#0, neer appearing in a stored file at all.3.1.16 de%latename of a particular compression algorithm. This algorithm is used, in compression mode7, in conforming PNG datastreams. /eflate is a member of the LZfamil# of compressionmethods. !t is defined in

  • 8/13/2019 Esempio Di Relazione Sul PNG

    4/37

    formal definition of luminance is in .5?. !nformall# it is the perceied brightness,or greyscaleleel, of a colour. uminance and chromaticitytogether full# define aperceied colour.3.1.29 ,-77data compression algorithm described b# 2i and empel in their %=66 paper

  • 8/13/2019 Esempio Di Relazione Sul PNG

    5/37

    3.1.43 reduced ima&epass of the interlaced PNG imageextracted from thePNG imageb#pass extraction.3.1.44 re%erence ima&erectangular arra# of rectangularpixels, each haing the same number of samples, eitherthree (red, green, blue) or four (red, green, blue, alpha). 8er# reference image can be

    represented exactl# b# a PNG datastreamand eer# PNG datastream can be conertedinto a reference image. 8ach channelhas a sample depthin the range % to %&. ll samplesin the same channel hae the same sample depth. /ifferent channels ma# hae differentsample depths.3.1.45 /+ mer&in&conerting an image in which the red, green, and blue samplesfor eachpixelhae thesame alue, and the same sample depth, into an image with a single greyscalechannel.3.1.46 sampleintersection of a channeland apixelin an image.3.1.47 sample depthnumber of bits used to represent a samplealue. !n an indexed-colourPNG image,

    samples are stored in thepaletteand thus the sample depth is alwa#s 4 b# definition of thepalette. !n other t#pes of PNG image it is the same as the bit depth.3.1.48 sample depth scalin&mapping of a range of samplealues onto the full range of a sample depthallowed ina PNG image.3.1.49 scanlinerow ofpixelswithin an image or interlaced PNG image.3.1.50 source ima&eimage which is presented to a PNG encoder.3.1.51 truecolourimage representation in which eachpixelis defined b# samples, representing red, green,and blue intensities and optionall# an alphasample (in which case it is referred to astruecolour with alpha).3.1.52 hite pointchromaticityof a computer displa#As nominal white alue.3.1.53 libparticular format for data that hae been compressed using deflate-st#le compression.lso the name of a librar# containing a sample implementation of this method. The formatis defined in

  • 8/13/2019 Esempio Di Relazione Sul PNG

    6/37

    ost $ignificant @#te of a multi-bytealue.

    4 Concepts4.1 ImagesThis !nternational $tandard specifies the PNG datastream, and places some re1uirements on PNGencoders, which generate PNG datastreams, PNG decoders, which interpret PNG datastreams, and PNGeditors, which transform one PNG datastream into another. !t does not specif# the interface between anapplication and either a PNG encoder, decoder, or editor. The precise form in which an image is presented toan encoder or deliered b# a decoder is not specified. "our kinds of image are distinguished.

    a. The source imageis the image presented to a PNG encoder.

    b. The reference image, which onl# exists conceptuall#, is a rectangular arra# ofrectangular pixels, all haing the same width and height, and all containing thesame number of unsigned integer samples, either three (red, green, blue) or four(red, green, blue, alpha). The arra# of all samples of a particular kind (red, green,blue, or alpha) is called a channel. 8ach channel has a sample depth in the range %to %&, which is the number of bits used b# eer# sample in the channel. /ifferentchannels ma# hae different sample depths. The red, green, and blue samplesdetermine the intensities of the red, green, and blue components of the pixelAscolour3 if the# are all ;ero, the pixel is black, and if the# all hae their maximumalues (5sampledepth-%), the pixel is white. The alpha sample determines a pixelAsdegree of opacit#, where ;ero means full# transparent and the maximum aluemeans full# opa1ue. !n a three-channel reference image all pixels are full# opa1ue.(!t is also possible for a four-channel reference image to hae all pixels full#opa1ue3 the difference is that the latter has a specific alpha sample depth, whereas

    the former does not.) 8ach hori;ontal row of pixels is called a scanline. Pixels areordered from left to right within each scanline, and scanlines are ordered from top tobottom. PNG encoder ma# transform the source image directl# into a PNG image,but conceptuall# it first transforms the source image into a reference image, thentransforms the reference image into a PNG image. /epending on the t#pe of sourceimage, the transformation from the source image to a reference image ma# re1uirethe loss of information. That transformation is be#ond the scope of this !nternational$tandard. The reference image, howeer, can alwa#s be recoered exactl# from aPNG datastream.

    c. The PNG imageis obtained from the reference image b# a series oftransformations+ alpha separation, indexing, G@ merging, alpha compaction, and

    sample depth scaling. "ie t#pes of PNG image are defined (see &.%+ olour t#pesand alues). (!f the PNG encoder actuall# transforms the source image directl# intothe PNG image, and the source image format is alread# similar to the PNG imageformat, the encoder ma# be able to aoid doing some of these transformations.)lthough not all sample depths in the range % to %& bits are explicitl# supported inthe PNG image, the number of significant bits in each channel of the referenceimage ma# be recorded. ll channels in the PNG image hae the same sampledepth. PNG encoder generates a PNG datastream from the PNG image. PNGdecoder takes the PNG datastream and recreates the PNG image.

    d. The deli%ered imageis constructed from the PNG image obtained b# decoding aPNG datastream. No specific format is specified for the deliered image. iewerpresents an image to the user as close to the appearance of the original sourceimage as it can achiee.

    The relationships between the four kinds of image are illustrated infigure 9.%.

    http://www.w3.org/TR/PNG/#3bytehttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#figure41http://www.w3.org/TR/PNG/#figure41http://www.w3.org/TR/PNG/#figure41http://www.w3.org/TR/PNG/#3bytehttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#figure41
  • 8/13/2019 Esempio Di Relazione Sul PNG

    7/37

    The relationships between samples, channels, pixels, and sample depth are illustrated in figure 9.5.

    4.2 Colour spaces

    The G@ colour space in which colour samples are situated ma# be specified in one of three wa#s+

    a. b# an ! profile3

    b. b# specif#ing explicitl# that the colour space is sG@ when the samples conform to this colourspace3

    c. b# specif#ing the alue of gamma and the %=:% !8x,ychromaticities of the red, green, and blueprimaries used in the image and the reference white point.

    "or high-end applications the first method proides the most flexibilit# and control. The second methodenables one particular colour space to be indicated. The third method enables the exact chromaticities of theG@ data to be specified, along with the gamma correction (the power function relating the desired displa#output with the image samples) to be applied (see nnex + Gamma and chromaticit#). !t is recommendedthat explicit gamma information also be proided when either the first or second method is used, for use b#PNG decoders that do not support full ! profiles or the sG@ colour space. $uch PNG decoders can stillmake sensible use of gamma information. PNG decoders are strongl# encouraged to use this information,plus information about the displa# s#stem, in order to present the image to the iewer in a wa# thatreproduces as closel# as possible what the imageAs original author saw .

    http://www.w3.org/TR/PNG/#figure42http://www.w3.org/TR/PNG/#C-GammaAppendixhttp://www.w3.org/TR/PNG/#figure42http://www.w3.org/TR/PNG/#C-GammaAppendix
  • 8/13/2019 Esempio Di Relazione Sul PNG

    8/37

    Gamma correction is not applied to the alpha channel, if present. lpha samples alwa#s represent a linearfraction of full opacit#.

    4.3 Reference image to PNG image transformation

    4.3.1 Introduction

    number of transformations are applied to the reference image to create the PNG image to be encoded(see figure 9.:). The transformations are applied in the following se1uence, where s1uare brackets mean thetransformation is optional+

    [alpha separation]

    indexing or ( [RGB merging] [alpha compaction] )

    sample depth scaling

    'hen eer# pixel is either full# transparent or full# opa1ue, the alpha separation, alpha compaction, andindexing transformations can cause the recoered reference image to hae an alpha sample depth differentfrom the original reference image, or to hae no alpha channel. This has no effect on the degree of opacit# ofan# pixel. The two reference images are considered e1uialent, and the transformations are consideredlossless. 8ncoders that neertheless wish to presere the alpha sample depth ma# elect not to performtransformations that would alter the alpha sample depth.

    4.3.2 Alpha separation!f all alpha samples in a reference image hae the maximum alue, then the alpha channel ma# be omitted,resulting in an e1uialent image that can be encoded more compactl#.

    4.3.3 Indexing!f the number of distinct pixel alues is 5>& or less, and the G@ sample depths are not greater than 4, andthe alpha channel is absent or exactl# 4 bits deep or eer# pixel is either full# transparent or full# opa1ue,then an alternatie representation called indexed-colour ma# be more efficient for encoding. 8ach pixel isreplaced b# an index into a palette. The palette is a list of entries each containing three 4-bit samples (red,green, blue). !f an alpha channel is present, there is also a parallel table of 4-bit alpha samples.

    http://www.w3.org/TR/PNG/#figure43http://www.w3.org/TR/PNG/#figure43
  • 8/13/2019 Esempio Di Relazione Sul PNG

    9/37

    suggested palette or palettes ma# be constructed een when the PNG image is not indexed-colour in orderto assist iewers that are capable of displa#ing onl# a limited number of colours.

    "or indexed-colour images, encoders can rearrange the palette so that the table entries with the maximumalpha alue are grouped at the end. !n this case the table can be encoded in a shortened form that does notinclude these entries.

    4.3.4 RGB merging!f the red, green, and blue channels hae the same sample depth, and for each pixel the alues of the red,green, and blue samples are e1ual, then these three channels ma# be merged into a single gre#scalechannel.

    4.3.5 Alpha compaction"or non-indexed images, if there exists an G@ (or gre#scale) alue such that all pixels with that alue arefull# transparent while all other pixels are full# opa1ue, then the alpha channel can be represented more

    compactl# b# merel# identif#ing the G@ (or gre#scale) alue that is transparent.

    4.3.6 Sample depth scaling!n the PNG image, not all sample depths are supported (see &.%+olour t#pes and alues), and all channelsshall hae the same sample depth. ll channels of the PNG image use the smallest allowable sample depththat is not less than an# sample depth in the reference image, and the possible sample alues in thereference image are linearl# mapped into the next allowable range for the PNG image. "igure 9.>shows howsamples of depth : might be mapped into samples of depth 9.

    llowing onl# a few sample depths reduces the number of cases that decoders hae to cope with. $ampledepth scaling is reersible with no loss of data, because the reference image sample depths can be recorded

    in the PNG datastream. !n the absence of recorded sample depths, the reference image sample depthe1uals the PNG image sample depth. $ee %5.>+ $ample depth scalingand %:.%5+ $ample depth rescaling.

    http://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#figure45http://www.w3.org/TR/PNG/#figure45http://www.w3.org/TR/PNG/#12Sample-depth-scalinghttp://www.w3.org/TR/PNG/#13Sample-depth-rescalinghttp://www.w3.org/TR/PNG/#13Sample-depth-rescalinghttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#figure45http://www.w3.org/TR/PNG/#12Sample-depth-scalinghttp://www.w3.org/TR/PNG/#13Sample-depth-rescaling
  • 8/13/2019 Esempio Di Relazione Sul PNG

    10/37

  • 8/13/2019 Esempio Di Relazione Sul PNG

    11/37

    4.5.1 Introduction conceptual model of the process of encoding a PNG image is gien in figure 9.6. The steps refer to theoperations on the arra# of pixels or indices in the PNG image. The palette and alpha table are not encoded inthis wa#.

    a. Pass extraction+ to allow for progressie displa#, the PNG image pixels can be

    rearranged to form seeral smaller images called reduced images or passes.b. $canline seriali;ation+ the image is seriali;ed a scanline at a time. Pixels are

    ordered left to right in a scanline and scanlines are ordered top to bottom.

    c. "iltering+ each scanline is transformed into a filtered scanline using one of thedefined filter t#pes to prepare the scanline for image compression.

    d. ompression+ occurs on all the filtered scanlines in the image.

    e. hunking+ the compressed image is diided into conenientl# si;ed chunks. nerror detection code is added to each chunk.

    f. /atastream construction+ the chunks are inserted into the datastream.

    4.5.2 Pass extractionPass extraction (see figure 9.4) splits a PNG image into a se1uence of reduced images where the first imagedefines a coarse iew and subse1uent images enhance this coarse iew until the last image completes thePNG image. The set of reduced images is also called an interlaced PNG image. Two interlace methods aredefined in this !nternational $tandard. The first method is a null method3 pixels are stored se1uentiall# fromleft to right and scanlines from top to bottom. The second method makes multiple scans oer the image toproduce a se1uence of seen reduced images. The seen passes for a sample image are illustrated in figure9.4. $ee clause 4+!nterlacing and pass extraction.

    http://www.w3.org/TR/PNG/#figure47http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#figure47http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#8Interlace
  • 8/13/2019 Esempio Di Relazione Sul PNG

    12/37

    4.5.3 Scanline serialization8ach row of pixels, called a scanline, is represented as a se1uence of b#tes.

    4.5.4 FilteringPNG standardi;es one filter method and seeral filter t#pes that ma# be used to prepare image data forcompression. !t transforms the b#te se1uence in a scanline to an e1ual length se1uence of b#tes precededb# a filter t#pe b#te (see figure 9.=for an example). The filter t#pe b#te defines the specific filtering to beapplied to a specific scanline. The encoder shall use onl# a single filter method for an interlaced PNG image,but ma# use different filter t#pes for each scanline in a reduced image. $ee clause =+ "iltering.

    4.5.5 CompressionThe se1uence of filtered scanlines in the pass or passes of the PNG image is compressed (see figure 9.%7)b# one of the defined compression methods. The concatenated filtered scanlines form the input to thecompression stage. The output from the compression stage is a single compressed datastream. $ee

    clause %7+ ompression.

    http://www.w3.org/TR/PNG/#figure49http://www.w3.org/TR/PNG/#figure49http://www.w3.org/TR/PNG/#9Filtershttp://www.w3.org/TR/PNG/#figure410http://www.w3.org/TR/PNG/#figure410http://www.w3.org/TR/PNG/#10Compressionhttp://www.w3.org/TR/PNG/#figure49http://www.w3.org/TR/PNG/#9Filtershttp://www.w3.org/TR/PNG/#figure410http://www.w3.org/TR/PNG/#10Compression
  • 8/13/2019 Esempio Di Relazione Sul PNG

    13/37

    4.5.6 Chunkinghunking proides a conenient breakdown of the compressed datastream into manageable chunks(see figure 9.%7). 8ach chunk has its own redundanc# check. $ee clause %%+ hunk specifications.

    4.6 Additional informationncillar# information ma# be associated with an image. /ecoders ma# ignore all or some of the ancillar#information. The t#pes of ancillar# information proided are described in Table 9.%.

    able 4.1 ypes o% ancillary in%ormation

    Type of

    information

    Description

    @ackground colour $olid background colour to be used when presenting the image if nobetter option is aailable.

    Gamma andchromaticit#

    Gamma characteristic of the image with respect to the desired outputintensit#, and chromaticit# characteristics of the G@ alues used in the

    image.! profile /escription of the colour space (in the form of an !nternational olor

    onsortium (!) profile) to which the samples in the image conform.

    !mage histogram 8stimates of how fre1uentl# the image uses each palette entr#.

    Ph#sical pixeldimensions

    !ntended pixel si;e and aspect ratio to be used in presenting the PNGimage.

    $ignificant bits The number of bits that are significant in the samples.

    sG@ colourspace

    rendering intent (as defined b# the !nternational olor onsortium)and an indication that the image samples conform to this colour space.

    $uggested palette reduced palette that ma# be used when the displa# deice is notcapable of displa#ing the full range of colours in the image.

    http://www.w3.org/TR/PNG/#figure410http://www.w3.org/TR/PNG/#figure410http://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#table41http://www.w3.org/TR/PNG/#figure410http://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#table41
  • 8/13/2019 Esempio Di Relazione Sul PNG

    14/37

    Textual data Textual information (which ma# be compressed) associated with theimage.

    Time The time when the PNG image was last modified.

    Transparenc# lpha information that allows the reference image to be reconstructed

    when the alpha channel is not retained in the PNG image.

    4.7 PNG datastream

    4.7.1 ChunksThe PNG datastream consists of a PNG signature (see >.5+ PNG signature)followed b# a se1uence ofchunks (see clause %%+ hunk specifications). 8ach chunk has a chunk t#pe which specifies its function.

    4.7.2 Chunk typesThere are %4 chunk t#pes defined in this !nternational $tandard. hunk t#pes are four-b#te se1uences

    chosen so that the# correspond to readable labels when interpreted in the !$C &9&.!D+%==% character set.The first four are termed critical chunks, which shall be understood and correctl# interpreted according to theproisions of this !nternational $tandard. These are+

    a.IHDR+ image header, which is the first chunk in a PNG datastream.

    b.PLTE+ palette table associated with indexed PNG images.

    c.IDAT+ image data chunks.

    d.IEND+ image trailer, which is the last chunk in a PNG datastream.The remaining %9 chunk t#pes are termed ancillar# chunk t#pes, which encoders ma# generate anddecoders ma# interpret.

    a. Transparenc# information+ tRNS(see %%.:.5+ Transparenc# information).

    b. olour space information+ cHRM, gAMA, iCCP, sBIT, sRGB(see %%.:.:+ olourspace information).

    c. Textual information+ iTXt, tEXt, zTXt(see %%.:.9+ Textual information).

    d. iscellaneous information+bKGD, hIST,pHYs, sPLT(see %%.:.>+ iscellaneousinformation).

    e. Time information+ tIME(see %%.:.&+ Time stamp information).

    4.8 Error handling8rrors in a PNG datastream fall into two general classes+

    a. transmission errors or damage to a computer file s#stem, which tend to corruptmuch or all of the datastream3

    b. s#ntax errors, which appear as inalid alues in chunks, or as missing or misplacedchunks. $#ntax errors can be caused not onl# b# encoding mistakes, but also b#the use of registered or priate alues, if those alues are unknown to the decoder.

    PNG decoders should detect errors as earl# as possible, recoer from errors wheneer possible, and failgracefull# otherwise. The error handling philosoph# is described in detail in %:.5+ 8rror handling.

    4.9 Extension and registration"or some facilities in PNG, there are a number of alternaties defined, and this !nternational $tandard allowsother alternaties to be defined b# registration. ccording to the rules for the designation and operation ofregistration authorities in the !$C*!8 /irecties, the !$C and !8 ouncils hae designated the following asthe registration authorit#+

    The World-Wide Web Consortium Host at ERCIM

    The Registration Authority for PNGINRIA- Sophia Antipolis

    BP 93

    http://www.w3.org/TR/PNG/#5PNG-file-signaturehttp://www.w3.org/TR/PNG/#5PNG-file-signaturehttp://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11transinfohttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11sBIThttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11addnlcolinfohttp://www.w3.org/TR/PNG/#11addnlcolinfohttp://www.w3.org/TR/PNG/#11iTXthttp://www.w3.org/TR/PNG/#11tEXthttp://www.w3.org/TR/PNG/#11zTXthttp://www.w3.org/TR/PNG/#11zTXthttp://www.w3.org/TR/PNG/#11textinfohttp://www.w3.org/TR/PNG/#11bKGDhttp://www.w3.org/TR/PNG/#11hISThttp://www.w3.org/TR/PNG/#11pHYshttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11addnlsiinfohttp://www.w3.org/TR/PNG/#11addnlsiinfohttp://www.w3.org/TR/PNG/#11tIMEhttp://www.w3.org/TR/PNG/#11tIMEhttp://www.w3.org/TR/PNG/#11timestampinfohttp://www.w3.org/TR/PNG/#13Decoders.Errorshttp://www.w3.org/TR/PNG/#13Decoders.Errorshttp://www.w3.org/TR/PNG/#13Decoders.Errorshttp://www.w3.org/TR/PNG/#5PNG-file-signaturehttp://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11transinfohttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11sBIThttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11addnlcolinfohttp://www.w3.org/TR/PNG/#11addnlcolinfohttp://www.w3.org/TR/PNG/#11iTXthttp://www.w3.org/TR/PNG/#11tEXthttp://www.w3.org/TR/PNG/#11zTXthttp://www.w3.org/TR/PNG/#11textinfohttp://www.w3.org/TR/PNG/#11bKGDhttp://www.w3.org/TR/PNG/#11hISThttp://www.w3.org/TR/PNG/#11pHYshttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11addnlsiinfohttp://www.w3.org/TR/PNG/#11addnlsiinfohttp://www.w3.org/TR/PNG/#11tIMEhttp://www.w3.org/TR/PNG/#11timestampinfohttp://www.w3.org/TR/PNG/#13Decoders.Errors
  • 8/13/2019 Esempio Di Relazione Sul PNG

    15/37

    06902 Sophia Antipolis Cedex

    FRANCE

    Email:[email protected]

    To ensure timel# processing the egistration uthorit# should be contacted b# email.

    The following entities ma# be registered+

    a. chunk t#pe3b. text ke#word.The following entities are resered for future standardi;ation+

    a. undefined field alues less than %543

    b. filter method3

    c. filter t#pe3

    d. interlace method3

    e. compression method.

    5 Datastream structure5.1 IntroductionThis clause defines the PNG signature and the basic properties of chunks. !ndiidual chunk t#pes arediscussed in clause %%+ hunk specifications.

    5.2 PNG signatureThe first eight b#tes of a PNG datastream alwa#s contain the following (decimal) alues+

    137 80 78 71 13 10 26 10

    This signature indicates that the remainder of the datastream contains a single PNG image, consisting of aseries of chunks beginning with an IHDRchunk and ending with an IENDchunk.

    5.3 Chunk layout

    8ach chunk consists of three or four fields (see figure >.%). The meaning of the fields is described in Table>.%. The chunk data field ma# be empt#.

    able 5.1 hunk %ields

    ength four-b#te unsigned integer giing the number of b#tes in the chunkAs data field.The length counts onl# the data field, not itself, the chunk t#pe, or the . 2erois a alid length. lthough encoders and decoders should treat the length asunsigned, its alue shall not exceed 5:%-% b#tes.

    hunkT#pe

    se1uence of four b#tes defining the chunk t#pe. 8ach b#te of a chunk t#pe isrestricted to the decimal alues &> to =7 and =6 to %55. These correspond to theuppercase and lowercase !$C &9& letters (A-Zand a-z) respectiel# forconenience in description and examination of PNG datastreams. 8ncoders anddecoders shall treat the chunk t#pes as fixed binar# alues, not character strings.

    http://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#table51http://www.w3.org/TR/PNG/#table51http://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#table51http://www.w3.org/TR/PNG/#table51
  • 8/13/2019 Esempio Di Relazione Sul PNG

    16/37

    "or example, it would not be correct to represent the chunk t#pe IDATb# the

    e1uialents of those letters in the B$ 5 character set. dditional namingconentions for chunk t#pes are discussed in >.9+ hunk naming conentions.

    hunk

    /ata

    The data b#tes appropriate to the chunk t#pe, if an#. This field can be of ;ero

    length. four-b#te (#clic edundanc# ode) calculated on the preceding b#tes in

    the chunk, including the chunk t#pe field and chunk data fields, but not includingthe length field. The can be used to check for corruption of the data. The is alwa#s present, een for chunks containing no data. $ee >.>+ #clicedundanc# ode algorithm.

    The chunk data length ma# be an# number of b#tes up to the maximum3 therefore, implementors cannotassume that chunks are aligned on an# boundaries larger than b#tes.

    5.4 Chunk naming conventionshunk t#pes are chosen to be meaningful names when the b#tes of the chunk t#pe are interpreted as !$C

    &9& letters. hunk t#pes are assigned so that a decoder can determine some properties of a chunk eenwhen the t#pe is not recogni;ed. These rules allow safe, flexible extension of the PNG format, b# allowing aPNG decoder to decide what to do when it encounters an unknown chunk. (The chunk t#pes standardi;ed inthis !nternational $tandard are defined in clause %%+ hunk specifications,and the wa# to add non-standardchunks is defined in clause %9+ 8ditors and extensions.) The naming rules are normall# of interest onl# whenthe decoder does not recogni;e the chunkAs t#pe.

    "our bits of the chunk t#pe, the propert# bits, namel# bit > (alue :5) of each b#te, are used to cone# chunkproperties. This choice means that a human can read off the assigned properties according to whether theletter corresponding to each b#te of the chunk t#pe is uppercase (bit > is 7) or lowercase (bit > is %).Eoweer, decoders should test the properties of an unknown chunk t#pe b# numericall# testing the specifiedbits3 testing whether a character is uppercase or lowercase is inefficient, and een incorrect if a locale-specific case definition is used.

    The propert# bits are an inherent part of the chunk t#pe, and hence are fixed for an# chunk t#pe.

    Thus, CHNKand cHNkwould be unrelated chunk t#pes, not the same chunk with different properties.The semantics of the propert# bits are defined inTable >.5.

    able 5.2 emantics o% property bits

    ncillar# bit+first b#te

    7 (uppercase) Fcritical,% (lowercase) Fancillar#.

    ritical chunks are necessar# for successful displa# ofthe contents of the datastream, for example the imageheader chunk (IHDR). decoder tr#ing to extract the

    image, upon encountering an unknown chunk t#pe inwhich the ancillar# bit is 7, shall indicate to the user thatthe image contains information it cannot safel# interpret.ncillar# chunks are not strictl# necessar# in order to

    meaningfull# displa# the contents of the datastream, forexample the time chunk (tIME). decoder

    encountering an unknown chunk t#pe in which theancillar# bit is % can safel# ignore the chunk andproceed to displa# the image.

    Priate bit+second b#te

    7 (uppercase) Fpublic,% (lowercase) Fpriate.

    public chunk is one that is defined in this !nternational$tandard or is registered in the list of PNG special-purpose public chunk t#pes maintained b# theegistration uthorit# (see 9.=8xtension andregistration). pplications can also define priate

    (unregistered) chunk t#pes for their own purposes. Thenames of priate chunks hae a lowercase secondletter, while public chunks will alwa#s be assigned

    http://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#5Chunk-naming-conventionshttp://www.w3.org/TR/PNG/#5CRC-algorithmhttp://www.w3.org/TR/PNG/#5CRC-algorithmhttp://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#table52http://www.w3.org/TR/PNG/#table52http://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11tIMEhttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#5Chunk-naming-conventionshttp://www.w3.org/TR/PNG/#5CRC-algorithmhttp://www.w3.org/TR/PNG/#5CRC-algorithmhttp://www.w3.org/TR/PNG/#11Chunkshttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#table52http://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11tIMEhttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#4Concepts.Registration
  • 8/13/2019 Esempio Di Relazione Sul PNG

    17/37

    names with uppercase second letters. /ecoders do notneed to test the priate-chunk propert# bit, since it hasno functional significance3 it is simpl# an administratieconenience to ensure that public and priate chunknames will not conflict. $ee clause %9+8ditors and

    extensionsand %5.%7.5+ Bse of priate chunks.

    eseredbit+ thirdb#te

    7 (uppercase) in thisersion of PNG.!f the resered bit is%, the datastreamdoes not conform tothis ersion of PNG.

    The significance of the case of the third letter of thechunk name is resered for possible future extension. !nthis !nternational $tandard, all chunk names shall haeuppercase third letters.

    $afe-to-cop# bit+fourth b#te

    7 (uppercase) Funsafe to cop#,% (lowercase) F safeto cop#.

    This propert# bit is not of interest to pure decoders, butit is needed b# PNG editors. This bit defines the properhandling of unrecogni;ed chunks in a datastream that isbeing modified. ules for PNG editors are discussedfurther in %9.5+ @ehaiour of PNG editors.

    8P8 The h#pothetical chunk t#pe 0cHNk0 has the propert# bits+

    cHNk x:5H x5&H x5:H x55H x%&H x%5H x%%H x%7H x4H x6H x>H x9H x5H x H %

    !n PNG, the :5-bit is initiali;ed to all %As, and then the data from each b#te is processed from the leastsignificant bit (%) to the most significant bit (%54). fter all the data b#tes are processed, the is inerted(its ones complement is taken). This alue is transmitted (stored in the datastream) $@ first. "or thepurpose of separating into b#tes and ordering, the least significant bit of the :5-bit is defined to be thecoefficient of the x31term.

    Practical calculation of the often emplo#s a precalculated table to accelerate the computation. $eennex /+$ample #clic edundanc# ode implementation.

    5.6 Chunk ordering

    The constraints on the positioning of the indiidual chunks are listed in Table >.:and illustrateddiagrammaticall# infigure >.5and figure >.:. These lattice diagrams represent the constraints on positioningimposed b# this !nternational $tandard. The lines in the diagrams define partial ordering relationships.hunks higher up shall appear before chunks lower down. hunks which are hori;ontall# aligned and appearbetween two other chunk t#pes (higher and lower than the hori;ontall# aligned chunks) ma# appear in an#order between the two higher and lower chunk t#pes to which the# are connected. The superscriptassociated with the chunk t#pe is defined inTable >.9.!t indicates whether the chunk is mandator#, optional,or ma# appear more than once. ertical bar between two chunk t#pes indicates alternaties.

    able 5.3 hunk orderin& rules

    Critical chunks

    (shall appear in this order, except PLTEis optional)

    Chunk

    name

    Multiple

    allowed

    Ordering constraints

    http://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#12Use-of-private-chunkshttp://www.w3.org/TR/PNG/#14Orderinghttp://www.w3.org/TR/PNG/#2-ISO-3309http://www.w3.org/TR/PNG/#G-ITU-T-V42http://www.w3.org/TR/PNG/#D-CRCAppendixhttp://www.w3.org/TR/PNG/#D-CRCAppendixhttp://www.w3.org/TR/PNG/#table53http://www.w3.org/TR/PNG/#figure52http://www.w3.org/TR/PNG/#figure52http://www.w3.org/TR/PNG/#figure53http://www.w3.org/TR/PNG/#table54http://www.w3.org/TR/PNG/#table54http://www.w3.org/TR/PNG/#table54http://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#12Use-of-private-chunkshttp://www.w3.org/TR/PNG/#14Orderinghttp://www.w3.org/TR/PNG/#2-ISO-3309http://www.w3.org/TR/PNG/#G-ITU-T-V42http://www.w3.org/TR/PNG/#D-CRCAppendixhttp://www.w3.org/TR/PNG/#table53http://www.w3.org/TR/PNG/#figure52http://www.w3.org/TR/PNG/#figure53http://www.w3.org/TR/PNG/#table54http://www.w3.org/TR/PNG/#11PLTE
  • 8/13/2019 Esempio Di Relazione Sul PNG

    18/37

    IHDR No $hall be first

    PLTE No @efore first IDAT

    IDAT Ies ultiple IDATchunks shall be consecutie

    IEND No $hall be lastAncillary chunks

    (need not appear in this order)

    Chunk

    name

    Multiple

    allowed

    Ordering constraints

    cHRM No @efore PLTEand IDAT

    gAMA No @efore PLTEand IDAT

    iCCP No @efore PLTEand IDAT. !f the iCCPchunk is present,

    the sRGBchunk should not be present.sBIT No @efore PLTEand IDAT

    sRGB No @efore PLTEand IDAT. !f the sRGBchunk is present,

    the iCCPchunk should not be present.

    bKGD No fter PLTE3 before IDAT

    hIST No fter PLTE3 before IDAT

    tRNS No fter PLTE3 before IDAT

    pHYs No @efore IDAT

    sPLT Ies @efore IDAT

    tIME No None

    iTXt Ies None

    tEXt Ies None

    zTXt Ies None

    able 5.4 eanin& o% symbols used in lattice dia&rams

    Symbol Meaning

    H Cne or more

    % Cnl# one

    J 2ero or one

    K 2ero or more

    L lternatie

    http://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sBIThttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11bKGDhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11hISThttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11pHYshttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11tIMEhttp://www.w3.org/TR/PNG/#11iTXthttp://www.w3.org/TR/PNG/#11tEXthttp://www.w3.org/TR/PNG/#11zTXthttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sBIThttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11bKGDhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11hISThttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11pHYshttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11tIMEhttp://www.w3.org/TR/PNG/#11iTXthttp://www.w3.org/TR/PNG/#11tEXthttp://www.w3.org/TR/PNG/#11zTXt
  • 8/13/2019 Esempio Di Relazione Sul PNG

    19/37

  • 8/13/2019 Esempio Di Relazione Sul PNG

    20/37

    6 Reference image to PNG image transformation6.1 Colour types and valuess explained in 9.9+PNG imagethere are fie t#pes of PNG image. orresponding to each t#pe is a colourt#pe, which is the sum of the following alues+ % (palette used), 5 (truecolour used) and 9 (alpha used).Gre#scale and truecolour images ma# hae an explicit alpha channel. The PNG image t#pes andcorresponding colour t#pes are listed inTable &.%.

    able 6.1 )*+ ima&e types and colour types

    PNG image type Colour type

    Gre#scale 7

    Truecolour 5

    !ndexed-colour :

    Gre#scale with alpha 9

    Truecolour with alpha &The allowed bit depths and sample depths for each PNG image t#pe are listed in %%.5.5+ IHDR !mage

    header.

    Gre#scale samples represent luminance if the transfer cure is indicated (b#gAMA,sRGB, or iCCP) or

    deice-dependent gre#scale if not. G@ samples represent calibrated colour information if the colour spaceis indicated (b# gAMAand cHRM, or sRGB, or iCCP) or uncalibrated deice-dependent colour if not.

    $ample alues are not necessaril# proportional to light intensit#3 the gAMAchunk specifies the relationship

    between sample alues and displa# output intensit#. Diewers are strongl# encouraged to compensateproperl#. $ee 9.5+ olour spaces, %:.%:+ /ecoder gamma handlingand nnex + Gamma and chromaticit#.

    6.2 Alpha representation!n a PNG datastream transparenc# ma# be represented in one of four wa#s, depending on the PNG imaget#pe (see 9.:.5+lpha separationand 9.:.>+lpha compaction).

    a. Truecolour with alpha, gre#scale with alpha+ an alpha channel is part of the imagearra#.

    b. Truecolour, gre#scale+ tRNSchunk contains a single pixel alue distinguishing thefull# transparent pixels from the full# opa1ue pixels.

    c. !ndexed-colour+ tRNSchunk contains the alpha table that associates an alphasample with each palette entr#.

    d. Truecolour, gre#scale, indexed-colour+ there is no tRNSchunk present and allpixels are full# opa1ue.

    n alpha channel included in the image arra# has 4-bit or %&-bit samples, the same si;e as the othersamples. The alpha sample for each pixel is stored immediatel# following the gre#scale or G@ samples of

    the pixel. n alpha alue of ;ero represents full transparenc#, and a alue of 5 sampledepth- % represents fullopacit#. !ntermediate alues indicate partiall# transparent pixels that can be composited against abackground image to #ield the deliered image.

    The colour alues in a pixel are not premultiplied b# the alpha alue assigned to the pixel. This rule issometimes called 0unassociated0 or 0non-premultiplied0 alpha. (nother common techni1ue is to storesample alues premultiplied b# the alpha alue3 in effect, such an image is alread# composited against ablack background. PNG does not use premultiplied alpha. !n conse1uence an image editor can take a PNGimage and easil# change its transparenc#.) $ee %5.9+lpha channel creationand %:.%&+lpha channelprocessing.

    7 Encoding the PNG image as a PNG datastream7.1 Integers and byte orderll integers that re1uire more than one b#te shall be in network b#te order (as illustrated in figure 6.%)+ themost significant b#te comes first, then the less significant b#tes in descending order of significance ($@

    http://www.w3.org/TR/PNG/#4Concepts.PNGImagehttp://www.w3.org/TR/PNG/#4Concepts.PNGImagehttp://www.w3.org/TR/PNG/#table6.1http://www.w3.org/TR/PNG/#table6.1http://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#4Concepts.ColourSpaceshttp://www.w3.org/TR/PNG/#13Decoder-gamma-handlinghttp://www.w3.org/TR/PNG/#13Decoder-gamma-handlinghttp://www.w3.org/TR/PNG/#C-GammaAppendixhttp://www.w3.org/TR/PNG/#4Concepts.Implied-alphahttp://www.w3.org/TR/PNG/#4Concepts.Implied-alphahttp://www.w3.org/TR/PNG/#4Concepts.Implied-alphahttp://www.w3.org/TR/PNG/#4Concepts.Alpha-indexinghttp://www.w3.org/TR/PNG/#4Concepts.Alpha-indexinghttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#12Alpha-channel-creationhttp://www.w3.org/TR/PNG/#13Alpha-channel-processinghttp://www.w3.org/TR/PNG/#13Alpha-channel-processinghttp://www.w3.org/TR/PNG/#figure71http://www.w3.org/TR/PNG/#4Concepts.PNGImagehttp://www.w3.org/TR/PNG/#table6.1http://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#4Concepts.ColourSpaceshttp://www.w3.org/TR/PNG/#13Decoder-gamma-handlinghttp://www.w3.org/TR/PNG/#C-GammaAppendixhttp://www.w3.org/TR/PNG/#4Concepts.Implied-alphahttp://www.w3.org/TR/PNG/#4Concepts.Alpha-indexinghttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#11tRNShttp://www.w3.org/TR/PNG/#12Alpha-channel-creationhttp://www.w3.org/TR/PNG/#13Alpha-channel-processinghttp://www.w3.org/TR/PNG/#13Alpha-channel-processinghttp://www.w3.org/TR/PNG/#figure71
  • 8/13/2019 Esempio Di Relazione Sul PNG

    21/37

    $@ for two-b#te integers, $@ @5 @% $@ for four-b#te integers). The highest bit (alue %54) of a b#te isnumbered bit 63 the lowest bit (alue %) is numbered bit 7. Dalues are unsigned unless otherwise noted.Dalues explicitl# noted as signed are represented in twoAs complement notation.

    PNG four-b#te unsigned integers are limited to the range 7 to 5 :%-% to accommodate languages that haedifficult# with unsigned four-b#te alues. $imilarl# PNG four-b#te signed integers are limited to the range -(5:%-%) to 5:%-% to accommodate languages that hae difficult# with the alue -5:%.

    7.2 Scanlines PNG image (or pass, see clause 4+!nterlacing and pass extraction) is a rectangular pixel arra#, with pixelsappearing left-to-right within each scanline, and scanlines appearing top-to-bottom. The si;e of each pixel isdetermined b# the number of bits per pixel.

    Pixels within a scanline are alwa#s packed into a se1uence of b#tes with no wasted bits between pixels.

    $canlines alwa#s begin on b#te boundaries. Permitted bit depths and colour t#pes are restricted so that in allcases the packing is simple and efficient.

    !n PNG images of colour t#pe 7 (gre#scale) each pixel is a single sample, which ma# hae precision lessthan a b#te (%, 5, or 9 bits). These samples are packed into b#tes with the leftmost sample in the high-orderbits of a b#te followed b# the other samples for the scanline.

    !n PNG images of colour t#pe : (indexed-colour) each pixel is a single palette index. These indices arepacked into b#tes in the same wa# as the samples for colour t#pe 7.

    'hen there are multiple pixels per b#te, some low-order bits of the last b#te of a scanline ma# go unused.The contents of these unused bits are not specified.

    PNG images that are not indexed-colour images ma# hae sample alues with a bit depth of %&. $uchsample alues are in network b#te order ($@ first, $@ second). PNG permits multi-sample pixels onl# with4 and %&-bit samples, so multiple samples of a single pixel are neer packed into one b#te.

    7.3 FilteringPNG allows the scanline data to be filtered before it is compressed. "iltering can improe the compressibilit#of the data. The filter step itself results in a se1uence of b#tes of the same si;e as the incoming se1uence,but in a different representation, preceded b# a filter t#pe b#te. "iltering does not reduce the si;e of theactual scanline data. ll PNG filters are strictl# lossless.

    /ifferent filter t#pes can be used for different scanlines, and the filter algorithm is specified for each scanlineb# a filter t#pe b#te. The filter t#pe b#te is not considered part of the image data, but it is included in thedatastream sent to the compression step. n intelligent encoder can switch filters from one scanline to thenext. The method for choosing which filter to emplo# is left to the encoder.

    $ee clause =+ "iltering.

    8 Interlacing and pass extraction8.1 Introduction

    http://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#9Filtershttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#9Filters
  • 8/13/2019 Esempio Di Relazione Sul PNG

    22/37

    Pass extraction (see figure 9.4) splits a PNG image into a se1uence of reduced images (the interlaced PNGimage) where the first image defines a coarse iew and subse1uent images enhance this coarse iew untilthe last image completes the PNG image. This allows progressie displa# of the interlaced PNG image b#the decoder and allows images to 0fade in0 when the# are being displa#ed on-the-fl#. Cn aerage, interlacingslightl# expands the datastream si;e, but it can gie the user a meaningful displa# much more rapidl#.

    8.2 Interlace methodsTwo interlace methods are defined in this !nternational $tandard, methods 7 and %. Cther alues of interlacemethod are resered for future standardi;ation (see 9.=+ 8xtension and registration).

    'ith interlace method 7, the null method, pixels are extracted se1uentiall# from left to right, and scanlinesse1uentiall# from top to bottom. The interlaced PNG image is a single reduced image.

    !nterlace method %, known as dam6, defines seen distinct passes oer the image. 8ach pass transmits asubset of the pixels in the reference image. The pass in which each pixel is transmitted (numbered from % to6) is defined b# replicating the following 4-b#-4 pattern oer the entire image, starting at the upper left corner+

    "igure 9.4shows the seen passes of interlace method %. 'ithin each pass, the selected pixels aretransmitted left to right within a scanline, and selected scanlines se1uentiall# from top to bottom. "orexample, pass 5 contains pixels 9, %5, 57, etc. of scanlines 7, 4, %&, etc. (where scanline 7, pixel 7 is theupper left corner). The last pass contains all of scanlines %, :, >, etc. The transmission order is defined so

    that all the scanlines transmitted in a pass will hae the same number of pixels3 this is necessar# for properapplication of some of the filters. The interlaced PNG image consists of a se1uence of seen reducedimages. "or example, if the PNG image is %& b# %& pixels, then the third pass will be a reduced image of twoscanlines, each containing four pixels (seefigure 9.4).

    $canlines that do not completel# fill an integral number of b#tes are padded as defined in 6.5+ $canlines.

    9 Filtering9.1 Filter methods and filter types"iltering transforms the PNG image with the goal of improing compression. PNG allows for a number offilter methods. ll the reduced images in an interlaced image shall use a single filter method. Cnl# filtermethod 7 is defined b# this !nternational $tandard. Cther filter methods are resered for futurestandardi;ation (see 9.=8xtension and registration). "ilter method 7 proides a set of fie filter t#pes, andindiidual scanlines in each reduced image ma# use different filter t#pes.

    PNG imposes no additional restriction on which filter t#pes can be applied to an interlaced PNG image.Eoweer, the filter t#pes are not e1uall# effectie on all t#pes of data. $ee %5.4+ "ilter selection.

    "iltering transforms the b#te se1uence in a scanline to an e1ual length se1uence of b#tes preceded b# thefilter t#pe. "ilter t#pe b#tes are associated onl# with non-empt# scanlines. No filter t#pe b#tes are present inan empt# pass. $ee %:.4+ !nterlacing and progressie displa#.

    9.2 Filter types for filter method 0"ilters are applied to b#tes, not to pixels, regardless of the bit depth or colour t#pe of the image. The filtersoperate on the b#te se1uence formed b# a scanline that has been represented as described in

    http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#7Scanlinehttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#12Filter-selectionhttp://www.w3.org/TR/PNG/#12Filter-selectionhttp://www.w3.org/TR/PNG/#13Progressive-displayhttp://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#figure48http://www.w3.org/TR/PNG/#7Scanlinehttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#12Filter-selectionhttp://www.w3.org/TR/PNG/#13Progressive-display
  • 8/13/2019 Esempio Di Relazione Sul PNG

    23/37

    6.5+ $canlines.!f the image includes an alpha channel, the alpha data is filtered in the same wa# as theimage data.

    "ilters ma# use the original alues of the following b#tes to generate the new b#te alue+

    x the b#te being filtered3

    a the b#te corresponding to x in the pixel immediatel# before the pixel containing x (or theb#te immediatel# before x, when the bit depth is less than 4)3

    b the b#te corresponding to x in the preious scanline3

    c the b#te corresponding to b in the pixel immediatel# before the pixel containing b (or theb#te immediatel# before b, when the bit depth is less than 4).

    "igure =.%shows the relatie positions of the b#tes x, a, b, and c.

    PNG filter method 7 defines fie basic filter t#pes as listed in Table =.%. Orig(y)denotes the orginal

    (unfiltered) alue of b#te y. Filt(y)denotes the alue after a filter has been applied. Recon(y)denotes

    the alue after the corresponding reconstruction function has been applied. The filter function for the Paetht#pe PaethPredictoris defined below.

    "ilter method 7 specifies exactl# this set of fie filter t#pes and this shall not be extended. This ensures that

    decoders need not decompress the data to determine whether it contains unsupported filter t#pes+ it issufficient to check the filter method in IHDR.

    able 9.1 ilter types

    Type Name Filter Function Reconstruction Function

    7 None Filt(x) = Orig(x) Recon(x) = Filt(x)

    % $ub Filt(x) = Orig(x) - Orig(a) Recon(x) = Filt(x) + Recon(a)

    5 Bp Filt(x) = Orig(x) - Orig(b) Recon(x) = Filt(x) + Recon(b)

    : erage Filt(x) = Orig(x) -

    floor((Orig(a) + Orig(b)) / 2)

    Recon(x) = Filt(x) +

    floor((Recon(a) + Recon(b)) / 2)

    9 Paeth Filt(x) = Orig(x) -PaethPredictor(Orig(a), Orig(b),

    Orig(c))

    Recon(x) = Filt(x) +

    PaethPredictor(Recon(a), Recon(b),

    Recon(c))

    "or all filters, the b#tes 0to the left of0 the first pixel in a scanline shall be treated as being ;ero. "or filters thatrefer to the prior scanline, the entire prior scanline and b#tes 0to the left of0 the first pixel in the prior scanlineshall be treated as being ;eroes for the first scanline of a reduced image.

    To reerse the effect of a filter re1uires the decoded alues of the prior pixel on the same scanline, the pixelimmediatel# aboe the current pixel on the prior scanline, and the pixel Must to the left of the pixel aboe.

    Bnsigned arithmetic modulo 5>& is used, so that both the inputs and outputs fit into b#tes. "ilters are appliedto each b#te regardless of bit depth. The se1uence of Filtalues is transmitted as the filtered scanline.

    9.3 Filter type 3: AverageThe sum Orig(a) + Orig(b)shall be performed without oerflow (using at least nine-bitarithmetic). floor()indicates that the result of the diision is rounded to the next lower integer if fractional3

    in other words, it is an integer diision or right shift operation.

    9.4 Filter type 4: PaethThe Paeth filter function computes a simple linear function of the three neighbouring pixels (left, aboe,upper left), then chooses as predictor the neighbouring pixel closest to the computed alue. The algorithmused in this !nternational $tandard is an adaptation of the techni1ue due to lan '. Paeth

  • 8/13/2019 Esempio Di Relazione Sul PNG

    24/37

    The calculations within the PaethPredictor function shall be performed exactl#, without oerflow.

    The order in which the comparisons are performed is critical and shall not be altered. The function tries toestablish in which of the three directions (ertical, hori;ontal, or diagonal) the gradient of the image issmallest.

    8xactl# the same PaethPredictor function is used b# both encoder and decoder.

    10 Compression10.1 Compression method 0Cnl# PNG compression method 7 is defined b# this !nternational $tandard. Cther alues of compressionmethod are resered for future standardi;ation (see 9.=+ 8xtension and registration). PNG compressionmethod 7 is deflate*inflate compression with a sliding window (which is an upper bound on the distancesappearing in the deflate stream) of at most :56&4 b#tes. /eflate compression is an 266 deriatie 7?.

    "or PNG compression method 7, the ;lib compression method*flags code shall specif# method code 4(deflate compression) and an 266 window si;e of not more than :56&4 b#tes. The ;lib compression methodnumber is not the same as the PNG compression method number in theIHDRchunk (see

    %%.5.5IHDR !mage header). The additional flags shall not specif# a preset dictionar#.

    !f the data to be compressed contain %&:49 b#tes or fewer, the PNG encoder ma# set the window si;e b#rounding up to a power of 5 (5>& minimum). This decreases the memor# re1uired for both encoding anddecoding, without adersel# affecting the compression ratio.

    The compressed data within the ;lib datastream are stored as a series of blocks, each of which canrepresent raw (uncompressed) data, 266-compressed data encoded with fixed Euffman codes, or 266-compressed data encoded with custom Euffman codes. marker bit in the final block identifies it as the last

    http://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#G-ZLhttp://www.w3.org/TR/PNG/#G-ZLhttp://www.w3.org/TR/PNG/#2-RFC-1950http://www.w3.org/TR/PNG/#2-RFC-1950http://www.w3.org/TR/PNG/#2-RFC-1950http://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#4Concepts.Registrationhttp://www.w3.org/TR/PNG/#G-ZLhttp://www.w3.org/TR/PNG/#2-RFC-1950http://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDR
  • 8/13/2019 Esempio Di Relazione Sul PNG

    25/37

    block, allowing the decoder to recogni;e the end of the compressed datastream. "urther details on thecompression algorithm and the encoding are gien in the deflate specification .5+ PNG signature)followed b# a se1uence ofchunks. 8ach chunk has a chunk t#pe which specifies its function. This clause defines the PNG chunk t#pesstandardi;ed in this !nternational $tandard. The PNG datastream structure is defined inclause >+/atastream structure.This also defines the order in which chunks ma# appear. "or details specificto encoders see %5.%%+hunking. "or details specific to decoders see %:.>+ hunking.

    11.2 Critical chunks

    11.2.1 Generalritical chunks are those chunks that are absolutel# re1uired in order to successfull# decode a PNG imagefrom a PNG datastream. 8xtension chunks ma# be defined as critical chunks (see clause %9+ 8ditors andextensions), though this practice is strongl# discouraged.

    alid PNG datastream shall begin with a PNG signature, immediatel# followed b# anIHDRchunk, then oneor moreIDATchunks, and shall end with an IENDchunk. Cnl# one IHDRchunk and oneIENDchunk are

    allowed in a PNG datastream.

    11.2.2IHDRImage headerThe four-b#te chunk t#pe field contains the decimal alues

    73 72 68 82

    The IHDRchunk shall be the first chunk in the PNG datastream. !t contains+

    'idth 9 b#tes

    Eeight 9 b#tes

    @it depth % b#te

    olour t#pe % b#te

    http://www.w3.org/TR/PNG/#2-RFC-1951http://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11iTXthttp://www.w3.org/TR/PNG/#11iTXthttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11zTXthttp://www.w3.org/TR/PNG/#11zTXthttp://www.w3.org/TR/PNG/#10CompressionCM0http://www.w3.org/TR/PNG/#5PNG-file-signaturehttp://www.w3.org/TR/PNG/#5PNG-file-signaturehttp://www.w3.org/TR/PNG/#5DataRephttp://www.w3.org/TR/PNG/#5DataRephttp://www.w3.org/TR/PNG/#5DataRephttp://www.w3.org/TR/PNG/#12Chunk-processinghttp://www.w3.org/TR/PNG/#12Chunk-processinghttp://www.w3.org/TR/PNG/#13Chunkinghttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#2-RFC-1951http://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11iTXthttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11zTXthttp://www.w3.org/TR/PNG/#10CompressionCM0http://www.w3.org/TR/PNG/#5PNG-file-signaturehttp://www.w3.org/TR/PNG/#5DataRephttp://www.w3.org/TR/PNG/#12Chunk-processinghttp://www.w3.org/TR/PNG/#13Chunkinghttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#14EditorsExthttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IDAThttp://www.w3.org/TR/PNG/#11IENDhttp://www.w3.org/TR/PNG/#11IHDRhttp://www.w3.org/TR/PNG/#11IEND
  • 8/13/2019 Esempio Di Relazione Sul PNG

    26/37

    ompression method % b#te

    "ilter method % b#te

    !nterlace method % b#te

    'idth and height gie the image dimensions in pixels. The# are PNG four-b#te unsigned integers. 2ero is an

    inalid alue.@it depth is a single-b#te integer giing the number of bits per sample or per palette index (not per pixel).Dalid alues are %, 5, 9, 4, and %&, although not all alues are allowed for all colour t#pes. $ee &.%+ olourt#pes and alues.

    olour t#pe is a single-b#te integer that defines the PNG image t#pe. Dalid alues are 7, 5, :, 9, and &.

    @it depth restrictions for each colour t#pe are imposed to simplif# implementations and to prohibitcombinations that do not compress well. The allowed combinations are defined in Table %%.%.

    able 11.1 lloed combinations o% colour type and bit depth

    PNG image type Colour

    type

    Allowed bit

    depths

    Interpretation

    Gre#scale 7 %, 5, 9, 4, %& 8ach pixel is a gre#scale sample

    Truecolour 5 4, %& 8ach pixel is an ,G,@ triple

    !ndexed-colour : %, 5, 9, 4 8ach pixel is a palette index3 a PLTEchunk

    shall appear.

    Gre#scale withalpha

    9 4, %& 8ach pixel is a gre#scale sample followed b#an alpha sample.

    Truecolour withalpha

    & 4, %& 8ach pixel is an ,G,@ triple followed b# analpha sample.

    The sample depth is the same as the bit depth except in the case of indexed-colour PNG images (colourt#pe :), in which the sample depth is alwa#s 4 bits (see 9.9+ PNG image).

    ompression method is a single-b#te integer that indicates the method used to compress the image data.Cnl# compression method 7 (deflate*inflate compression with a sliding window of at most :56&4 b#tes) isdefined in this !nternational $tandard. ll conforming PNG images shall be compressed with this scheme.

    "ilter method is a single-b#te integer that indicates the preprocessing method applied to the image databefore compression. Cnl# filter method 7 (adaptie filtering with fie basic filter t#pes) is defined in this!nternational $tandard. $ee clause =+ "ilteringfor details.

    !nterlace method is a single-b#te integer that indicates the transmission order of the image data. Two aluesare defined in this !nternational $tandard+ 7 (no interlace) or % (dam6 interlace). $ee clause 4+!nterlacingand pass extractionfor details.

    11.2.3PLTEPalette

    The four-b#te chunk t#pe field contains the decimal alues80 76 84 69

    The PLTEchunk contains from % to 5>& palette entries, each a three-b#te series of the form+

    ed % b#te

    Green % b#te

    @lue % b#te

    The number of entries is determined from the chunk length. chunk length not diisible b# : is an error.

    This chunk shall appear for colour t#pe :, and ma# appear for colour t#pes 5 and &3 it shall not appear forcolour t#pes 7 and 9. There shall not be more than one PLTEchunk.

    "or colour t#pe : (indexed-colour), the PLTEchunk is re1uired. The first entr# in PLTEis referenced b# pixel

    alue 7, the second b# pixel alue %, etc. The number of palette entries shall not exceed the range that canbe represented in the image bit depth (for example, 59F %& for a bit depth of 9). !t is permissible to hae

    http://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#table111http://www.w3.org/TR/PNG/#table111http://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#4Concepts.PNGImagehttp://www.w3.org/TR/PNG/#9Filtershttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#6Colour-valueshttp://www.w3.org/TR/PNG/#table111http://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#4Concepts.PNGImagehttp://www.w3.org/TR/PNG/#9Filtershttp://www.w3.org/TR/PNG/#8Interlacehttp://www.w3.org/TR/PNG/#8Interlace
  • 8/13/2019 Esempio Di Relazione Sul PNG

    27/37

    fewer entries than the bit depth would allow. !n that case, an# out-of-range pixel alue found in the imagedata is an error.

    "or colour t#pes 5 and & (truecolour and truecolour with alpha), the PLTEchunk is optional. !f present, it

    proides a suggested set of colours (from % to 5>&) to which the truecolour image can be 1uanti;ed if itcannot be displa#ed directl#. !t is, howeer, recommended that the sPLTchunk be used for this purpose,

    rather than the PLTEchunk. !f neither PLTEnorsPLTchunks are present and the image cannot be displa#ed

    directl#, 1uanti;ation has to be done b# the iewing s#stem. Eoweer, it is often preferable for the selectionof colours to be done once b# the PNG encoder. ($ee %5.&+ $uggested palettes.)

    Note that the palette uses 4 bits (% b#te) per sample regardless of the image bit depth. !n particular, thepalette is 4 bits deep een when it is a suggested 1uanti;ation of a %&-bit truecolour image.

    There is no re1uirement that the palette entries all be used b# the image, nor that the# all be different.

    11.2.4IDATImage dataThe four-b#te chunk t#pe field contains the decimal alues

    73 68 65 84

    The IDATchunk contains the actual image data which is the output stream of the compression algorithm.

    $ee clause =+ "ilteringand clause %7+ ompressionfor details.

    There ma# be multiple IDATchunks3 if so, the# shall appear consecutiel# with no other interening chunks.

    The compressed datastream is then the concatenation of the contents of the data fields of allthe IDATchunks.

    11.2.5IENDImage trailerThe four-b#te chunk t#pe field contains the decimal alues

    73 69 78 68

    The IENDchunk marks the end of the PNG datastream. The chunkAs data field is empt#.

    11.3 Ancillary chunks

    11.3.1 GeneralThe ancillar# chunks defined in this !nternational $tandard are listed in the order in 9.6.5+ hunk t#pes. This

    is not the order in which the# appear in a PNG datastream. ncillar# chunks ma# be ignored b# a decoder."or each ancillar# chunk, the actions described are under the assumption that the decoder is not ignoring thechunk.

    11.3.2 Transparency information

    11.3.2.1 tRNSTransparency

    The four-b#te chunk t#pe field contains the decimal alues

    116 82 78 83

    The tRNSchunk specifies either alpha alues that are associated with palette entries (for indexed-colour

    images) or a single transparent colour (for gre#scale and truecolour images). The tRNSchunk contains+

    Colour type 0

    Gre# sample alue 5 b#tes

    Colour type 2

    ed sample alue 5 b#tes

    @lue sample alue 5 b#tes

    Green sample alue 5 b#tes

    Colour type 3

    lpha for palette index 7 % b#te

    lpha for palette index % % b#te

    ...etc... % b#te

    http://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#12Suggested-paletteshttp://www.w3.org/TR/PNG/#12Suggested-paletteshttp://www.w3.org/TR/PNG/#9Filtershttp://www.w3.org/TR/PNG/#10Compressionhttp://www.w3.org/TR/PNG/#10Compressionhttp://www.w3.org/TR/PNG/#4Concepts.FormatTypeshttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#11sPLThttp://www.w3.org/TR/PNG/#12Suggested-paletteshttp://www.w3.org/TR/PNG/#9Filtershttp://www.w3.org/TR/PNG/#10Compressionhttp://www.w3.org/TR/PNG/#4Concepts.FormatTypes
  • 8/13/2019 Esempio Di Relazione Sul PNG

    28/37

    "or colour t#pe : (indexed-colour), the tRNSchunk contains a series of one-b#te alpha alues,

    corresponding to entries in the PLTEchunk. 8ach entr# indicates that pixels of the corresponding palette

    index shall be treated as haing the specified alpha alue. lpha alues hae the same interpretation as inan 4-bit full alpha channel+ 7 is full# transparent, 5>> is full# opa1ue, regardless of image bit depth.The tRNSchunk shall not contain more alpha alues than there are palette entries, but a tRNSchunk ma#

    contain fewer alues than there are palette entries. !n this case, the alpha alue for all remaining palette

    entries is assumed to be 5>>. !n the common case in which onl# palette index 7 need be made transparent,onl# a one-b#te tRNSchunk is needed, and when all palette indices are opa1ue, the tRNSchunk ma# be

    omitted.

    "or colour t#pes 7 or 5, two b#tes per sample are used regardless of the image bit depth (see 6.%+ !ntegersand b#te order). Pixels of the specified gre# sample alue or G@ sample alues are treated as transparent(e1uialent to alpha alue 7)3 all other pixels are to be treated as full# opa1ue (alpha alue 5 bitdepth-%). !f theimage bit depth is less than %&, the least significant bits are used and the others are 7.

    tRNSchunk shall not appear for colour t#pes 9 and &, since a full alpha channel is alread# present in those

    cases.

    NCT8 "or %&-bit gre#scale or truecolour data, onl# pixels matching the entire %&-bit alues in tRNSchunks are transparent. /ecodershae to postpone an# sample depth rescaling until after the pixels hae been tested for transparenc#.

    11.3.3 Colour space information

    11.3.3.1 cHRMPrimary chromaticities and white point

    The four-b#te chunk t#pe field contains the decimal alues

    99 72 82 77

    The cHRMchunk ma# be used to specif# the %=:% !8x,ychromaticities of the red, green, and blue displa#

    primaries used in the image, and the referenced white point. $ee nnex + Gamma and chromaticit#formore information. The iCCPand sRGBchunks proide more sophisticated support for colour management

    and control.

    The cHRMchunk contains+

    'hite point x 9 b#tes

    'hite point # 9 b#tesed x 9 b#tes

    ed # 9 b#tes

    Green x 9 b#tes

    Green # 9 b#tes

    @lue x 9 b#tes

    @lue # 9 b#tes

    8ach alue is encoded as a four-b#te PNG unsigned integer, representing thexor yalue times %77777.

    8P8 alue of 7.:%56 would be stored as the integer :%567.The cHRMchunk is allowed in all PNG datastreams, although it is of little alue for gre#scale images.

    n sRGBchunk oriCCPchunk, when present and recogni;ed, oerrides the cHRMchunk.

    11.3.3.2 gAMAImage gamma

    The four-b#te chunk t#pe field contains the decimal alues

    103 65 77 65

    The gAMAchunk specifies the relationship between the image samples and the desired displa# output

    intensit#. Gamma is defined in :.%.57+ gamma.

    !n fact specif#ing the desired displa# output intensit# is insufficient. !t is also necessar# to specif# the iewingconditions under which the output is desired. "or gAMA these are the reference iewing conditions of the

    sG@ specification

    iewing conditions is normall# handled b# a olour anagement $#stem. !f the adMustment is not performed,the error is usuall# small. pplications desiring high colour fidelit# ma# wish to use an sRGBchunk

    oriCCPchunk.

    The gAMAchunk contains+

    http://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#7Integers-and-byte-orderhttp://www.w3.org/TR/PNG/#7Integers-and-byte-orderhttp://www.w3.org/TR/PNG/#7Integers-and-byte-orderhttp://www.w3.org/TR/PNG/#C-GammaAppendixhttp://www.w3.org/TR/PNG/#C-GammaAppendixhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#3gammahttp://www.w3.org/TR/PNG/#3gammahttp://www.w3.org/TR/PNG/#2-IEC-61966-2-1http://www.w3.org/TR/PNG/#2-IEC-61966-2-1http://www.w3.org/TR/PNG/#2-IEC-61966-2-1http://www.w3.org/TR/PNG/#G-ISO-3664http://www.w3.org/TR/PNG/#G-ISO-3664http://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11PLTEhttp://www.w3.org/TR/PNG/#7Integers-and-byte-orderhttp://www.w3.org/TR/PNG/#7Integers-and-byte-orderhttp://www.w3.org/TR/PNG/#C-GammaAppendixhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#3gammahttp://www.w3.org/TR/PNG/#2-IEC-61966-2-1http://www.w3.org/TR/PNG/#G-ISO-3664http://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCP
  • 8/13/2019 Esempio Di Relazione Sul PNG

    29/37

    !mage gamma 9 b#tes

    The alue is encoded as a four-b#te PNG unsigned integer, representing gamma times %77777.

    8P8 gamma of %*5.5 would be stored as the integer 9>9>>.

    $ee %5.5+ 8ncoder gamma handlingand %:.%:+ /ecoder gamma handlingfor more information.

    n sRGBchunk oriCCPchunk, when present and recogni;ed, oerrides the gAMAchunk.

    11.3.3.3 iCCPEmbedded ICC profile

    The four-b#te chunk t#pe field contains the decimal alues

    105 67 67 80

    The iCCPchunk contains+

    Profile name %-6= b#tes (character string)

    Null separator % b#te (null character)

    ompression method % b#te

    ompressed profile n b#tes

    The profile name ma# be an# conenient name for referring to the profile. !t is case-sensitie. Profile namesshall contain onl# printable atin-% characters and spaces (onl# character codes :5-%5& and %&%-5>>decimal are allowed). eading, trailing, and consecutie spaces are not permitted. The onl# compressionmethod defined in this !nternational $tandard is method 7 (;lib datastream with deflate compression, see%7.:+ Cther uses of compression). The compression method entr# is followed b# a compressed profile thatmakes up the remainder of the chunk. /ecompression of this datastream #ields the embedded ! profile.

    !f the iCCPchunk is present, the image samples conform to the colour space represented b# the embedded

    ! profile as defined b# the !nternational olor onsortium

    also write gAMAandcHRMchunks that approximate the ! profile, to proide compatibilit# with applications

    that do not use the iCCPchunk. 'hen the iCCPchunk is present, PNG decoders that recogni;e it and are

    capable of colour management

    instead and interpret it according to

    PNG datastream should contain at most one embedded profile, whether specified explicitl# withan iCCPchunk or implicitl# with ansRGBchunk.

    11.3.3.4 sBITSignificant bits

    The four-b#te chunk t#pe field contains the decimal alues

    115 66 73 84

    To simplif# decoders, PNG specifies that onl# certain sample depths ma# be used, and further specifies thatsample alues should be scaled to the full range of possible alues at the sample depth. The sBITchunk

    defines the original number of significant bits (which can be less than or e1ual to the sample depth). Thisallows PNG decoders to recoer the original data losslessl# een if the data had a sample depth not directl#

    supported b# PNG.The sBITchunk contains+

    Colour type 0

    significant gre#scale bits % b#te

    Colour types 2 and 3

    significant red bits % b#te

    significant green bits % b#te

    significant blue bits % b#te

    Colour type 4

    significant gre#scale bits % b#te

    http://www.w3.org/TR/PNG/#12Encoder-gamma-handlinghttp://www.w3.org/TR/PNG/#12Encoder-gamma-handlinghttp://www.w3.org/TR/PNG/#13Decoder-gamma-handlinghttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#10CompressionOtherUseshttp://www.w3.org/TR/PNG/#G-ICChttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#G-ICChttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#2-ICC-1http://www.w3.org/TR/PNG/#2-ICC-1http://www.w3.org/TR/PNG/#2-ICC-1Ahttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sBIThttp://www.w3.org/TR/PNG/#12Encoder-gamma-handlinghttp://www.w3.org/TR/PNG/#13Decoder-gamma-handlinghttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11iCCPhttp://www.w3.org/TR/PNG/#10CompressionOtherUseshttp://www.w3.org/TR/PNG/#G-ICChttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#G-ICChttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#2-ICC-1http://www.w3.org/TR/PNG/#2-ICC-1Ahttp://www.w3.org/TR/PNG/#11gAMAhttp://www.w3.org/TR/PNG/#11cHRMhttp://www.w3.org/TR/PNG/#11sRGBhttp://www.w3.org/TR/PNG/#11sBIT
  • 8/13/2019 Esempio Di Relazione Sul PNG

    30/37

  • 8/13/2019 Esempio Di Relazione Sul PNG

    31/37

    @lue # &777

    'hen the sRGBchunk is present, it is recommended that decoders that recogni;e it and are capable of

    colour management

    that recogni;e the sRGBchunk but are not capable of colour management

    thegAMAand cHRMchunks, and use the alues gien aboe as if the# had appeared

    in gAMAandcHRMchunks.!t is recommended that the sRGBand iCCPchunks do not both appear in a PNG datastream.

    11.3.4 Textual information

    11.3.4.1 Introduction

    PNG proides thetEXt, iTXt,and zTXtchunks for storing text strings associated with the image, such as

    an image description or cop#right notice. e#words are used to indicate what each text string represents.n# number of such text chunks ma# appear, and more than one with the same ke#word is permitted.

    11.3.4.2 Keywords and text strings

    The following ke#words are predefined and should be used where appropriate.

    Title $hort (one line) title or caption for image

    uthor Name of imageAs creator

    /escription /escription of image (possibl# long)

    op#right op#right notice

    reation Time Time of original image creation

    $oftware $oftware used to create the image

    /isclaimer egal disclaimer

    'arning 'arning of nature of content$ource /eice used to create the image

    omment iscellaneous comment

    Cther ke#words ma# be defined for other purposes. e#words of general interest can be registered with thePNG egistration uthorit# (see 9.= 8xtension and registration). !t is also permitted to use priateunregistered ke#words. (Priate ke#words should be reasonabl# self-explanator#, in order to minimi;e thechance that the same ke#word is used for incompatible purposes b# different people.)

    e#words shall contain onl# printable atin-%=-%?characters and spaces3 that is, onl# charactercodes :5-%5& and %&%-5>> decimal are allowed. To reduce the chances for human misreading of a ke#word,leading spaces, trailing spaces, and consecutie spaces are not permitted in ke#w