1 /*
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1865 int numEntries = maxindex + 1;
1866 PLTE_red = new byte[numEntries];
1867 PLTE_green = new byte[numEntries];
1868 PLTE_blue = new byte[numEntries];
1869 System.arraycopy(red, 0, PLTE_red, 0, numEntries);
1870 System.arraycopy(green, 0, PLTE_green, 0, numEntries);
1871 System.arraycopy(blue, 0, PLTE_blue, 0, numEntries);
1872 PLTE_present = true;
1873 } else if (childName.equals("BackgroundIndex")) {
1874 bKGD_present = true;
1875 bKGD_colorType = PNGImageReader.PNG_COLOR_PALETTE;
1876 bKGD_index = getIntAttribute(child, "value");
1877 } else if (childName.equals("BackgroundColor")) {
1878 int red = getIntAttribute(child, "red");
1879 int green = getIntAttribute(child, "green");
1880 int blue = getIntAttribute(child, "blue");
1881 if (red == green && red == blue) {
1882 bKGD_colorType = PNGImageReader.PNG_COLOR_GRAY;
1883 bKGD_gray = red;
1884 } else {
1885 bKGD_red = red;
1886 bKGD_green = green;
1887 bKGD_blue = blue;
1888 }
1889 bKGD_present = true;
1890 }
1891 // } else if (childName.equals("ColorSpaceType")) {
1892 // } else if (childName.equals("NumChannels")) {
1893
1894 child = child.getNextSibling();
1895 }
1896 } else if (name.equals("Compression")) {
1897 Node child = node.getFirstChild();
1898 while (child != null) {
1899 String childName = child.getNodeName();
1900 if (childName.equals("NumProgressiveScans")) {
1901 // Use Adam7 if NumProgressiveScans > 1
1902 int scans = getIntAttribute(child, "value");
1903 IHDR_interlaceMethod = (scans > 1) ? 1 : 0;
1904 // } else if (childName.equals("CompressionTypeName")) {
|
1 /*
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1865 int numEntries = maxindex + 1;
1866 PLTE_red = new byte[numEntries];
1867 PLTE_green = new byte[numEntries];
1868 PLTE_blue = new byte[numEntries];
1869 System.arraycopy(red, 0, PLTE_red, 0, numEntries);
1870 System.arraycopy(green, 0, PLTE_green, 0, numEntries);
1871 System.arraycopy(blue, 0, PLTE_blue, 0, numEntries);
1872 PLTE_present = true;
1873 } else if (childName.equals("BackgroundIndex")) {
1874 bKGD_present = true;
1875 bKGD_colorType = PNGImageReader.PNG_COLOR_PALETTE;
1876 bKGD_index = getIntAttribute(child, "value");
1877 } else if (childName.equals("BackgroundColor")) {
1878 int red = getIntAttribute(child, "red");
1879 int green = getIntAttribute(child, "green");
1880 int blue = getIntAttribute(child, "blue");
1881 if (red == green && red == blue) {
1882 bKGD_colorType = PNGImageReader.PNG_COLOR_GRAY;
1883 bKGD_gray = red;
1884 } else {
1885 bKGD_colorType = PNGImageReader.PNG_COLOR_RGB;
1886 bKGD_red = red;
1887 bKGD_green = green;
1888 bKGD_blue = blue;
1889 }
1890 bKGD_present = true;
1891 }
1892 // } else if (childName.equals("ColorSpaceType")) {
1893 // } else if (childName.equals("NumChannels")) {
1894
1895 child = child.getNextSibling();
1896 }
1897 } else if (name.equals("Compression")) {
1898 Node child = node.getFirstChild();
1899 while (child != null) {
1900 String childName = child.getNodeName();
1901 if (childName.equals("NumProgressiveScans")) {
1902 // Use Adam7 if NumProgressiveScans > 1
1903 int scans = getIntAttribute(child, "value");
1904 IHDR_interlaceMethod = (scans > 1) ? 1 : 0;
1905 // } else if (childName.equals("CompressionTypeName")) {
|