001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.imaging.formats.png; 018 019import java.nio.charset.StandardCharsets; 020 021import org.apache.commons.imaging.common.BinaryFunctions; 022 023/** 024 * Type of a PNG chunk. 025 * 026 * @see <a href="http://www.w3.org/TR/PNG/#11Chunks">Portable Network Graphics Specification - Chunk specifications</a> 027 */ 028public enum ChunkType { 029 030 /** Image header */ 031 IHDR, 032 033 /** Palette */ 034 PLTE, 035 036 /** Image data */ 037 IDAT, 038 039 /** Image trailer */ 040 IEND, 041 042 /** Transparency */ 043 tRNS, 044 045 /** Primary chromaticities and white point */ 046 cHRM, 047 048 /** Image gamma */ 049 gAMA, 050 051 /** Embedded ICC profile */ 052 iCCP, 053 054 /** Significant bits*/ 055 sBIT, 056 057 /** Standard RGB colour space */ 058 sRGB, 059 060 /** Textual data */ 061 tEXt, 062 063 /** Compressed textual data */ 064 zTXt, 065 066 /** International textual data */ 067 iTXt, 068 069 /** Background colour */ 070 bKGD, 071 072 /** Image histogram */ 073 hIST, 074 075 /** Physical pixel dimensions */ 076 pHYs, 077 078 /** Physical scale */ 079 sCAL, 080 081 /** Suggested palette */ 082 sPLT, 083 084 /** Image last-modification time */ 085 tIME; 086 087 final byte[] array; 088 final int value; 089 090 ChunkType() { 091 final char[] chars = name().toCharArray(); 092 array = name().getBytes(StandardCharsets.UTF_8); 093 value = BinaryFunctions.charsToQuad(chars[0], chars[1], chars[2], chars[3]); 094 } 095}