Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
PNG
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Pixel format === {| class="wikitable floatcenter" |+ Allowed combinations of color type and bit depth<ref name="w3IHDR"/> ! rowspan=2| Color type ! rowspan=2| Channels ! colspan=5| Bits per channel |- ! 1 !! 2 !! 4 !! 8 !! 16 |- ! Indexed ! 1 | {{yes|1}}|| {{yes|2}}|| {{yes|4}}|| {{yes|8}}|| {{no|}} |- ! Grayscale ! 1 | {{yes|1}}|| {{yes|2}}|| {{yes|4}}|| {{yes|8}}|| {{yes|16}} |- ! Grayscale and alpha ! 2 | {{no| }}|| {{no| }}|| {{no| }}|| {{yes|16}}|| {{yes|32}} |- ! Truecolor ! 3 | {{no| }}|| {{no| }}|| {{no| }}|| {{yes|24}}|| {{yes|48}} |- ! Truecolor and alpha ! 4 | {{no| }}|| {{no| }}|| {{no| }}|| {{yes|32}}|| {{yes|64}} |} Pixels in PNG images are numbers that may be either indices of sample data in the [[Palette (computing)|palette]] or the sample data itself. The palette is a separate table contained in the PLTE chunk. Sample data for a single [[pixel]] consists of a tuple of between one and four numbers. Whether the pixel data represents palette indices or explicit sample values, the numbers are referred to as [[Channel (digital image)|channels]] and every number in the image is encoded with an identical format. The permitted formats encode each number as an unsigned integer value using a fixed number of bits, referred to in the PNG specification as the ''bit depth''. Notice that this is not the same as [[color depth]], which is commonly used to refer to the total number of bits in each pixel, not each channel. The permitted bit depths are summarized in the table along with the total number of bits used for each pixel. The number of channels depends on whether the image is grayscale or color and whether it has an [[alpha channel]]. PNG allows the following combinations of channels, called the ''color type''. [[File:PNG color depth comparison.png|thumb|upright=1.5|A demonstration of the color depth in a PNG file, in bits per channel. Left: 8 bits; Right: 16 bits. Note the [[Digital artifact|artifacts]], adjusted contrast for clarity.]] {| class=wikitable |- |0 (000<sub>2</sub>)|| grayscale |- |2 (010<sub>2</sub>)|| red, green and blue: rgb/truecolor |- |3 (011<sub>2</sub>)|| indexed: channel containing indices into a palette of colors |- |4 (100<sub>2</sub>)|| grayscale and alpha: level of [[Opacity (optics)|opacity]] for each pixel |- |6 (110<sub>2</sub>)|| red, green, blue and alpha |} The color type is specified as an 8-bit value however only the low three bits are used and, even then, only the five combinations listed above are permitted. So long as the color type is valid it can be considered as a bit field as summarized in the adjacent table: {| class="wikitable floatcenter" |+ PNG color types !rowspan=2| Color<br /> type !rowspan=2| Name !colspan=4| Binary !rowspan=2| Masks |- !title="undefined"| !!title="alpha"| A !!title="color"| C !!title="palette"| P |- ! 0 !! Grayscale | {{no|0}}||{{no|0}}||{{no|0}}||{{no|0}} | |- ! 2 !! Truecolor | {{no|0}}||{{no|0}}||{{yes|1}}||{{no|0}} | color |- ! 3 !! Indexed | {{no|0}}||{{no|0}}||{{yes|1}}||{{yes|1}} | color, palette |- ! 4 !! Grayscale and alpha | {{no|0}}||{{yes|1}}||{{no|0}}||{{no|0}} | alpha |- ! 6 !! Truecolor and alpha | {{no|0}}|| {{yes|1}}|| {{yes|1}}|| {{no|0}} | alpha, color |} * bit value 1: the image data stores palette indices. This is only valid in combination with bit value 2; * bit value 2: the image samples contain three channels of data encoding [[Trichromacy|trichromatic]] [[color]]s, otherwise the image samples contain one channel of data encoding [[relative luminance]], * bit value 4: the image samples also contain an alpha channel expressed as a linear measure of the opacity of the pixel. This is not valid in combination with bit value 1. With indexed color images, the palette always stores trichromatic colors at a depth of 8 bits per channel (24 bits per palette entry). Additionally, an optional list of 8-bit alpha values for the palette entries may be included; if not included, or if shorter than the palette, the remaining palette entries are assumed to be opaque. The palette must not have more entries than the image bit depth allows for, but it may have fewer (for example, if an image with 8-bit pixels only uses 90 colors then it does not need palette entries for all 256 colors). The palette must contain entries for all the pixel values present in the image. The standard allows indexed color PNGs to have 1, 2, 4 or 8 bits per pixel; grayscale images with no alpha channel may have 1, 2, 4, 8 or 16 bits per pixel. Everything else uses a bit depth per channel of either 8 or 16. The combinations this allows are given in the table above. The standard requires that decoders can read all supported color formats, but many image editors can only produce a small subset of them.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
PNG
(section)
Add topic