====== PNG ======
Dies ist ein binäres Format in Big-Endian Anordnung. Folgende Datentypen kommen zur Anwendung:
^char |String mit 8-Bit Kodierung |
^uint8 |vorzeichenlose 8-Bit Zahl |
^uint32 |vorzeichenlose 32-Bit Zahl |
Die Datei beginnt mit der Signatur. Danach folgen die einzelnen Blocks direkt aufeinander.
===== Signatur =====
[[/grundlagen/dateien/bilder/png#dateiaufbau|Details Signatur]]
Jede PNG Datei beginnt mit folgender Signatur:
<89 50 4E 47 0D 0A 1A 0A>
Auf die Signatur folgt direkt der erste Block.
===== Blockaufbau =====
[[/grundlagen/dateien/bilder/png#dateiaufbau|Details Blockaufbau]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|Blockgrösse |* |Blockdaten |
|Blockgrösse + 8 |4 Byte |uint32 |Prüfsumme |
Die Prüfsumme ist eine normale [[http://de.wikipedia.org/wiki/CRC-32|CRC-32]] Prüfsumme über Blocktyp und Blockdaten.
===== "IHDR" Block =====
[[/grundlagen/dateien/bilder/png#image_header|Details "IHDR" Block]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|4 Byte |uint32 |Bildbreite |
| 12|4 Byte |uint32 |Bildhöhe |
| 16|1 Byte |uint8 |Bittiefe |
| 17|1 Byte |uint8 |Farbmodell |
| 18|1 Byte |uint8 |Kompression |
| 19|1 Byte |uint8 |Prediktor |
| 20|1 Byte |uint8 |Interlacing |
| 21|4 Byte |uint32 |Prüfsumme |
Für das Farbmodell sind folgende Werte möglich:
^Wert ^Modell ^
| 0|Graustufen |
| 2|RGB |
| 3|RGB indexiert |
| 4|Graustufen mit Alphakanal |
| 6|RGB mit Alphakanal |
Kompression ist immer 0 (Deflate).
Prediktor ist immer 0 (PNG Prediktor).
Interlacing kann die Werte 0 (kein Interlacing) und 1 (Adam7) haben.
===== "PLTE" Block =====
[[/grundlagen/dateien/bilder/png#palette|Details "PLTE" Block]]
Dieser Block kommt nur im indexierten Farbraum vor, ist dann aber zwingend notwendig.
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|Blockgrösse |uint8 |Palette |
|Blockgrösse + 8 |4 Byte |uint32 |Prüfsumme |
Die Palette hat einen Eintrag für jede verwendete Farbe, welcher wiederum aus drei uint8 für den Rot-, Grün- und Blauanteil der Farbe besteht.
===== "IDAT" Block =====
[[/grundlagen/dateien/bilder/png#bilddaten|Details "IDAT" Block]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|Blockgrösse |* |Bilddaten |
|Blockgrösse + 8 |4 Byte |uint32 |Prüfsumme |
Falls mehrere IDAT Blöcke existieren, müssen die Bilddaten der einzelnen Blöcke in der Reihenfolge des Auftretens in der Datei zusammengesetzt werden.
===== "sRGB" Block =====
[[/grafik/farbkorrektur/bilder#srgb-deklaration|Details "sRGB" Block]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|1 Byte |uint8 |Umrechnungspriorität |
| 9|4 Byte |uint32 |Prüfsumme |
Ist dieser Block enthalten, so sind die Bilddaten im sRGB Farbraum.
Für die Umrechnungspriorität sind folgende Werte möglich:
^ 0|''/Perceptual'' |
^ 1|''/RelativeColorimetric'' |
^ 2|''/Saturation'' |
^ 3|''/AbsoluteColorimetric'' |
===== "iCCP" Block =====
[[/grafik/farbkorrektur/bilder#icc-profil|Details "iCCP" Block]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|* |char |Profilname |
| *|1 Byte |uint8 |0 |
| *|1 Byte |uint8 |Kompression |
| *|* |* |ICC-Profildaten |
| *|4 Byte |uint32 |Prüfsumme |
Der Profilname ist in ISO Latin-1, und kann im Namen selbst kein 0-Byte enthalten.
Kompression ist immer 0 (Deflate).
===== "gAMA" Block =====
[[/grafik/farbkorrektur/bilder#gama|Details "gAMA" Block]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|4 Byte |uint32 |Gammawert (invers) |
| 12|4 Byte |uint32 |Prüfsumme |
Der inverse Gammawert ist auf einer Skala von 0 - 100'000.
Formel zur Umrechnung in den Wert für PDF:
gamma = 100000.0 / gamma
===== "cHRM" Block =====
[[/grafik/farbkorrektur/bilder#chrm|Details "cHRM" Block]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|4 Byte |uint32 |xw |
| 12|4 Byte |uint32 |yw |
| 16|4 Byte |uint32 |xr |
| 20|4 Byte |uint32 |yr |
| 24|4 Byte |uint32 |xg |
| 28|4 Byte |uint32 |yg |
| 32|4 Byte |uint32 |xb |
| 36|4 Byte |uint32 |yb |
| 40|4 Byte |uint32 |Prüfsumme |
Die x und y Werte sind auf einer Skala von 0 - 100'000.
Formelsatz für die Umrechnung in PDF-Werte:
xw = xw / 100000.0
yw = yw / 100000.0
xr = xr / 100000.0
yr = yr / 100000.0
xg = xg / 100000.0
yg = yg / 100000.0
xb = xb / 100000.0
yb = yb / 100000.0
Xw = xw / yw
Yw = 1
Zw = (1 - xw - yw) / yw
zr = 1 - xr - yr
zg = 1 - xg - yg
zb = 1 - xb - yb
mxr = yg * zb - zg * yb
mxg = zr * yb - yr * zb
mxb = yr * zg - zr * yg
d = mxr * xr + mxg * xg + mxb * xb
Sr = (mxr * Xw + (yb * Zw - zb) * xg + (zg - yg * Zw) * xb) / d
Sg = (mxg * Xw + (yr * Zw - zr) * xb + (zb - yb * Zw) * xr) / d
Sb = (mxb * Xw + (yg * Zw - zg) * xr + (zr - yr * Zw) * xg) / d
Xr = xr * Sr
Yr = yr * Sr
Zr = zr * Sr
Xg = xg * Sg
Yg = yg * Sg
Zg = zg * Sg
Xb = xb * Sb
Yb = yb * Sb
Zb = zb * Sb
/WhitePoint [Xw Yw Zw]
/Matrix [Xr Yr Zr Xg Yg Zg Xb Yb Zb]
===== "IEND" Block =====
[[/grundlagen/dateien/bilder/png#bildende|Details "IEND" Block]]
^Position ^Grösse ^Typ ^Wert ^
| 0|4 Byte |uint32 |Blockgrösse |
| 4|4 Byte |char |Blocktyp |
| 8|4 Byte |uint32 |Prüfsumme |
Dieser Block enthält keine Blockdaten. Er markiert lediglich das Dateiende.