1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.imaging.formats.png; 18 19 import java.nio.charset.StandardCharsets; 20 21 import org.apache.commons.imaging.common.BinaryFunctions; 22 23 /** 24 * Type of a PNG chunk. 25 * 26 * @see <a href="http://www.w3.org/TR/PNG/#11Chunks">Portable Network Graphics Specification - Chunk specifications</a> 27 */ 28 public enum ChunkType { 29 30 /** Image header */ 31 IHDR, 32 33 /** Palette */ 34 PLTE, 35 36 /** Image data */ 37 IDAT, 38 39 /** Image trailer */ 40 IEND, 41 42 /** Transparency */ 43 tRNS, 44 45 /** Primary chromaticities and white point */ 46 cHRM, 47 48 /** Image gamma */ 49 gAMA, 50 51 /** Embedded ICC profile */ 52 iCCP, 53 54 /** Significant bits*/ 55 sBIT, 56 57 /** Standard RGB colour space */ 58 sRGB, 59 60 /** Textual data */ 61 tEXt, 62 63 /** Compressed textual data */ 64 zTXt, 65 66 /** International textual data */ 67 iTXt, 68 69 /** Background colour */ 70 bKGD, 71 72 /** Image histogram */ 73 hIST, 74 75 /** Physical pixel dimensions */ 76 pHYs, 77 78 /** Physical scale */ 79 sCAL, 80 81 /** Suggested palette */ 82 sPLT, 83 84 /** Image last-modification time */ 85 tIME; 86 87 final byte[] array; 88 final int value; 89 90 ChunkType() { 91 final char[] chars = name().toCharArray(); 92 array = name().getBytes(StandardCharsets.UTF_8); 93 value = BinaryFunctions.charsToQuad(chars[0], chars[1], chars[2], chars[3]); 94 } 95 }