diff options
| author | Hung-ying Tyan <tyanh@google.com> | 2012-08-24 02:00:01 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-08-24 02:00:02 -0700 |
| commit | 1e16dd6bdaa2ef99539f60e051a816f4ce9f3a3f (patch) | |
| tree | 90f4ae3a93181c317068c10068c181c9571fcf83 /src | |
| parent | 66e64517f9b2b18485f4436aecac54f1998f2823 (diff) | |
| parent | bdbf57f29db2c98dd2e0d05cd062c063fe90cd54 (diff) | |
| download | android_packages_apps_Gallery2-1e16dd6bdaa2ef99539f60e051a816f4ce9f3a3f.tar.gz android_packages_apps_Gallery2-1e16dd6bdaa2ef99539f60e051a816f4ce9f3a3f.tar.bz2 android_packages_apps_Gallery2-1e16dd6bdaa2ef99539f60e051a816f4ce9f3a3f.zip | |
Merge "Rename TiffInputStream to CountedDataInputStream" into gb-ub-photos-arches
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/gallery3d/exif/CountedDataInputStream.java (renamed from src/com/android/gallery3d/exif/TiffInputStream.java) | 14 | ||||
| -rw-r--r-- | src/com/android/gallery3d/exif/ExifParser.java | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/com/android/gallery3d/exif/TiffInputStream.java b/src/com/android/gallery3d/exif/CountedDataInputStream.java index 2b0054c46..dfd4a1a10 100644 --- a/src/com/android/gallery3d/exif/TiffInputStream.java +++ b/src/com/android/gallery3d/exif/CountedDataInputStream.java @@ -24,7 +24,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; -class TiffInputStream extends FilterInputStream { +class CountedDataInputStream extends FilterInputStream { private int mCount = 0; @@ -32,7 +32,7 @@ class TiffInputStream extends FilterInputStream { private final byte mByteArray[] = new byte[8]; private final ByteBuffer mByteBuffer = ByteBuffer.wrap(mByteArray); - protected TiffInputStream(InputStream in) { + protected CountedDataInputStream(InputStream in) { super(in); } @@ -42,26 +42,28 @@ class TiffInputStream extends FilterInputStream { @Override public int read(byte[] b) throws IOException { - return read(b, 0, b.length); + int r = in.read(b); + mCount += (r >= 0) ? r : 0; + return r; } @Override public int read(byte[] b, int off, int len) throws IOException { - int r = super.read(b, off, len); + int r = in.read(b, off, len); mCount += (r >= 0) ? r : 0; return r; } @Override public int read() throws IOException { - int r = super.read(); + int r = in.read(); mCount += (r >= 0) ? 1 : 0; return r; } @Override public long skip(long length) throws IOException { - long skip = super.skip(length); + long skip = in.skip(length); mCount += skip; return skip; } diff --git a/src/com/android/gallery3d/exif/ExifParser.java b/src/com/android/gallery3d/exif/ExifParser.java index 4249a7241..bd8a97dac 100644 --- a/src/com/android/gallery3d/exif/ExifParser.java +++ b/src/com/android/gallery3d/exif/ExifParser.java @@ -137,7 +137,7 @@ public class ExifParser { private static final int TAG_SIZE = 12; private static final int OFFSET_SIZE = 2; - private final TiffInputStream mTiffStream; + private final CountedDataInputStream mTiffStream; private final int mOptions; private int mIfdStartOffset = 0; private int mNumOfTagInIfd = 0; @@ -174,7 +174,7 @@ public class ExifParser { private ExifParser(InputStream inputStream, int options) throws IOException, ExifInvalidFormatException { seekTiffData(inputStream); - mTiffStream = new TiffInputStream(inputStream); + mTiffStream = new CountedDataInputStream(inputStream); mOptions = options; if (mTiffStream.getReadByteCount() == 0) { parseTiffHeader(); |
