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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @author Rustem Rafikov
19 * @version $Revision: 1.2 $
21 package org.apache.harmony.x.imageio.plugins.jpeg;
23 import javax.imageio.stream.ImageInputStream;
25 import org.apache.harmony.awt.gl.image.DecodingImageSource;
27 import java.io.InputStream;
28 import java.io.IOException;
31 * This allows usage of the java2d jpegdecoder with ImageInputStream in
32 * the JPEGImageReader. Temporary, only to make JPEGImageReader#read(..)
36 public class IISDecodingImageSource extends DecodingImageSource {
38 private final InputStream is;
40 public IISDecodingImageSource(ImageInputStream iis) {
41 is = new IISToInputStreamWrapper(iis);
45 protected boolean checkConnection() {
50 protected InputStream getInputStream() {
54 static class IISToInputStreamWrapper extends InputStream {
56 private ImageInputStream input;
58 public IISToInputStreamWrapper(ImageInputStream input) {
63 public int read() throws IOException {
68 public int read(byte[] b) throws IOException {
73 public int read(byte[] b, int off, int len) throws IOException {
74 return input.read(b, off, len);
78 public long skip(long n) throws IOException {
79 return input.skipBytes(n);
83 public boolean markSupported() {
84 return true; // This is orig
87 // This is an error in Harmony. Not all input streams
88 // have mark support and it is not ok to just return true.
89 // There should be an input.markSupported(). However, if
90 // this call returns false, nothing works anymore.
92 // The backside is that BitmapFactory uses a call to markSupport()
93 // to find out if it needs to warp the stream in a
94 // BufferedInputStream to get mark support, and this fails!
96 // Currently, the hack is in BitmapFactory, where we always
97 // wrap the stream in a BufferedInputStream.
101 public void mark(int readlimit) {
106 public void reset() throws IOException {
111 public void close() throws IOException {