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
2240 DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
2241 TemporalAccessor dt = formatter.parseBest(encodedTime,
2242 OffsetDateTime::from, LocalDateTime::from);
2243
2244 if (dt instanceof OffsetDateTime) {
2245 // Encoded time contains date time and zone offset
2246 retVal = (OffsetDateTime) dt;
2247 } else if (dt instanceof LocalDateTime) {
2248 /*
2249 * Encoded time contains only date and time. Since zone
2250 * offset information isn't available, we set to the default
2251 */
2252 LocalDateTime locDT = (LocalDateTime) dt;
2253 retVal = OffsetDateTime.of(locDT, ZoneOffset.UTC);
2254 }
2255 } catch (DateTimeParseException exception) {
2256 // No Op. Encoded time did not comply with ISO standard.
2257 }
2258 }
2259 return retVal;
2260 }
2261
2262 // Reset all instance variables to their initial state
2263 public void reset() {
2264 IHDR_present = false;
2265 PLTE_present = false;
2266 bKGD_present = false;
2267 cHRM_present = false;
2268 gAMA_present = false;
2269 hIST_present = false;
2270 iCCP_present = false;
2271 iTXt_keyword = new ArrayList<String>();
2272 iTXt_compressionFlag = new ArrayList<Boolean>();
2273 iTXt_compressionMethod = new ArrayList<Integer>();
2274 iTXt_languageTag = new ArrayList<String>();
2275 iTXt_translatedKeyword = new ArrayList<String>();
2276 iTXt_text = new ArrayList<String>();
2277 pHYs_present = false;
2278 sBIT_present = false;
2279 sPLT_present = false;
|
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
2240 DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
2241 TemporalAccessor dt = formatter.parseBest(encodedTime,
2242 OffsetDateTime::from, LocalDateTime::from);
2243
2244 if (dt instanceof OffsetDateTime) {
2245 // Encoded time contains date time and zone offset
2246 retVal = (OffsetDateTime) dt;
2247 } else if (dt instanceof LocalDateTime) {
2248 /*
2249 * Encoded time contains only date and time. Since zone
2250 * offset information isn't available, we set to the default
2251 */
2252 LocalDateTime locDT = (LocalDateTime) dt;
2253 retVal = OffsetDateTime.of(locDT, ZoneOffset.UTC);
2254 }
2255 } catch (DateTimeParseException exception) {
2256 // No Op. Encoded time did not comply with ISO standard.
2257 }
2258 }
2259 return retVal;
2260 }
2261
2262 boolean hasTransparentColor() {
2263 return tRNS_present &&
2264 (tRNS_colorType == PNGImageReader.PNG_COLOR_RGB ||
2265 tRNS_colorType == PNGImageReader.PNG_COLOR_GRAY);
2266 }
2267
2268 // Reset all instance variables to their initial state
2269 public void reset() {
2270 IHDR_present = false;
2271 PLTE_present = false;
2272 bKGD_present = false;
2273 cHRM_present = false;
2274 gAMA_present = false;
2275 hIST_present = false;
2276 iCCP_present = false;
2277 iTXt_keyword = new ArrayList<String>();
2278 iTXt_compressionFlag = new ArrayList<Boolean>();
2279 iTXt_compressionMethod = new ArrayList<Integer>();
2280 iTXt_languageTag = new ArrayList<String>();
2281 iTXt_translatedKeyword = new ArrayList<String>();
2282 iTXt_text = new ArrayList<String>();
2283 pHYs_present = false;
2284 sBIT_present = false;
2285 sPLT_present = false;
|