1 /*
2 * Copyright (c) 1999, 2010, 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
214 | ((getShort(st + 4)&0xFF) );
215 }
216 break;
217 case GRAY: // doesn't deal with 16 bit colors properly
218 case GRAY|ALPHA: // doesn't deal with 16 bit colors properly
219 pngassert(len==2);
220 /* REMIND: Discarding the LSB for 16 bit depth here
221 * means that the all pixels which match the MSB
222 * will be treated as transparent.
223 */
224 int t = getShort(st);
225 t = 0xFF & ((bitDepth == 16) ? (t >> 8) : t);
226 transparentPixel = (t<<16) | (t<< 8) | t;
227 break;
228 }
229 break;
230 case zTXtChunk: break;
231 }
232 return true;
233 }
234 public class PNGException extends IOException {
235 PNGException(String s) { super(s); }
236 }
237 /* this is changed
238 public void run() {
239 */
240 public void produceImage() throws IOException, ImageFormatException {
241 /* this is not needed
242 ImageConsumer t = target;
243 if(t!=null) try {
244 */
245 try {
246 for(int i=0; i<signature.length; i++)
247 if((signature[i]&0xFF)!=underlyingInputStream.read())
248 throw new PNGException("Chunk signature mismatch");
249
250 InputStream is = new BufferedInputStream(new InflaterInputStream(inputStream,new Inflater()));
251
252 getData();
253
|
1 /*
2 * Copyright (c) 1999, 2014, 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
214 | ((getShort(st + 4)&0xFF) );
215 }
216 break;
217 case GRAY: // doesn't deal with 16 bit colors properly
218 case GRAY|ALPHA: // doesn't deal with 16 bit colors properly
219 pngassert(len==2);
220 /* REMIND: Discarding the LSB for 16 bit depth here
221 * means that the all pixels which match the MSB
222 * will be treated as transparent.
223 */
224 int t = getShort(st);
225 t = 0xFF & ((bitDepth == 16) ? (t >> 8) : t);
226 transparentPixel = (t<<16) | (t<< 8) | t;
227 break;
228 }
229 break;
230 case zTXtChunk: break;
231 }
232 return true;
233 }
234 @SuppressWarnings("serial") // JDK-implementation class
235 public class PNGException extends IOException {
236 PNGException(String s) { super(s); }
237 }
238 /* this is changed
239 public void run() {
240 */
241 public void produceImage() throws IOException, ImageFormatException {
242 /* this is not needed
243 ImageConsumer t = target;
244 if(t!=null) try {
245 */
246 try {
247 for(int i=0; i<signature.length; i++)
248 if((signature[i]&0xFF)!=underlyingInputStream.read())
249 throw new PNGException("Chunk signature mismatch");
250
251 InputStream is = new BufferedInputStream(new InflaterInputStream(inputStream,new Inflater()));
252
253 getData();
254
|