diff options
| author | Hung-ying Tyan <tyanh@google.com> | 2012-08-26 20:14:48 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-08-26 20:14:49 -0700 |
| commit | f6513f51e9c8cc307164305215e4122bf93fb08d (patch) | |
| tree | 19a7510f1394ed66dc8c3d54a5ed8ad1dd9c1a32 /src | |
| parent | 7916a57fb06d625e5c544e289cd487622d2c3137 (diff) | |
| parent | d83a3749f50a8b493a12dfc96aaa0da2f9a6d08b (diff) | |
| download | android_packages_apps_Gallery2-f6513f51e9c8cc307164305215e4122bf93fb08d.tar.gz android_packages_apps_Gallery2-f6513f51e9c8cc307164305215e4122bf93fb08d.tar.bz2 android_packages_apps_Gallery2-f6513f51e9c8cc307164305215e4122bf93fb08d.zip | |
Merge "Read thumbnail into ExifData" into gb-ub-photos-arches
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/gallery3d/exif/ExifData.java | 57 | ||||
| -rw-r--r-- | src/com/android/gallery3d/exif/ExifReader.java | 14 |
2 files changed, 69 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/exif/ExifData.java b/src/com/android/gallery3d/exif/ExifData.java index 712698ef4..5b0e3d8e4 100644 --- a/src/com/android/gallery3d/exif/ExifData.java +++ b/src/com/android/gallery3d/exif/ExifData.java @@ -15,6 +15,9 @@ */ package com.android.gallery3d.exif; + +import java.util.ArrayList; + /** * This class stores the EXIF header in IFDs according to the JPEG specification. * It is the result produced by {@link ExifReader}. @@ -23,6 +26,8 @@ package com.android.gallery3d.exif; */ public class ExifData { private final IfdData[] mIfdDatas = new IfdData[IfdId.TYPE_IFD_COUNT]; + private byte[] mThumbnail; + private ArrayList<byte[]> mStripBytes = new ArrayList<byte[]>(); /** * Gets the IFD data of the specified IFD. @@ -44,4 +49,56 @@ public class ExifData { public void addIfdData(IfdData data) { mIfdDatas[data.getId()] = data; } + + /** + * Gets the compressed thumbnail. Returns null if there is no compressed thumbnail. + * + * @see #hasCompressedThumbnail() + */ + public byte[] getCompressedThumbnail() { + return mThumbnail; + } + + /** + * Sets the compressed thumbnail. + */ + public void setCompressedThumbnail(byte[] thumbnail) { + mThumbnail = thumbnail; + } + + /** + * Returns true it this header contains a compressed thumbnail. + */ + public boolean hasCompressedThumbnail() { + return mThumbnail != null; + } + + /** + * Adds an uncompressed strip. + */ + public void setStripBytes(int index, byte[] strip) { + if (index < mStripBytes.size()) { + mStripBytes.set(index, strip); + } else { + for (int i = mStripBytes.size(); i < index; i++) { + mStripBytes.add(null); + } + mStripBytes.add(strip); + } + } + + /** + * Gets the strip count + */ + public int getStripCount() { + return mStripBytes.size(); + } + + /** + * Gets the strip at the specified index. + * @exceptions #IndexOutOfBoundException + */ + public byte[] getStrip(int index) { + return mStripBytes.get(index); + } }
\ No newline at end of file diff --git a/src/com/android/gallery3d/exif/ExifReader.java b/src/com/android/gallery3d/exif/ExifReader.java index 125b6c65e..c259461f2 100644 --- a/src/com/android/gallery3d/exif/ExifReader.java +++ b/src/com/android/gallery3d/exif/ExifReader.java @@ -24,11 +24,11 @@ import java.io.InputStream; */ public class ExifReader { /** - * Parse the inputStream and return all Exif data. + * Parses the inputStream and and returns the EXIF data in an {@link ExifData}. * @throws ExifInvalidFormatException * @throws IOException */ - public ExifData getExifData(InputStream inputStream) throws ExifInvalidFormatException, + public ExifData read(InputStream inputStream) throws ExifInvalidFormatException, IOException { ExifParser parser = ExifParser.parse(inputStream); ExifData exifData = new ExifData(); @@ -56,6 +56,16 @@ public class ExifReader { } exifData.getIfdData(tag.getIfd()).setTag(tag); break; + case ExifParser.EVENT_COMPRESSED_IMAGE: + byte buf[] = new byte[parser.getCompressedImageSize()]; + parser.read(buf); + exifData.setCompressedThumbnail(buf); + break; + case ExifParser.EVENT_UNCOMPRESSED_STRIP: + buf = new byte[parser.getStripSize()]; + parser.read(buf); + exifData.setStripBytes(parser.getStripIndex(), buf); + break; } event = parser.next(); } |
