diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2013-04-02 23:47:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-04-02 23:47:03 +0000 |
commit | ca926f9c13fdd3f813811b02782d4fb4fb79d7f5 (patch) | |
tree | 6790d06c298040e62881542e1c27902b345d692f /gallerycommon | |
parent | 2b24604837aa9821d7e5ed409c2164ede803e0c4 (diff) | |
parent | 4bee0f203dc96652aca02516f6f2d7d2493fab52 (diff) | |
download | android_packages_apps_Gallery2-ca926f9c13fdd3f813811b02782d4fb4fb79d7f5.tar.gz android_packages_apps_Gallery2-ca926f9c13fdd3f813811b02782d4fb4fb79d7f5.tar.bz2 android_packages_apps_Gallery2-ca926f9c13fdd3f813811b02782d4fb4fb79d7f5.zip |
Merge "Speed improvements for ExifOutputStream." into gb-ub-photos-bryce
Diffstat (limited to 'gallerycommon')
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java | 8 | ||||
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java b/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java index 2fef9ede0..a1cf0fc85 100644 --- a/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java +++ b/gallerycommon/src/com/android/gallery3d/exif/ExifInterface.java @@ -20,6 +20,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.SparseIntArray; +import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.Closeable; @@ -758,7 +759,7 @@ public class ExifInterface { } InputStream is = null; try { - is = (InputStream) new FileInputStream(inFileName); + is = (InputStream) new BufferedInputStream(new FileInputStream(inFileName)); readExif(is); } catch (IOException e) { closeSilently(is); @@ -800,6 +801,7 @@ public class ExifInterface { } OutputStream s = getExifWriterStream(exifOutStream); s.write(jpeg, 0, jpeg.length); + s.flush(); } /** @@ -817,6 +819,7 @@ public class ExifInterface { } OutputStream s = getExifWriterStream(exifOutStream); bmap.compress(Bitmap.CompressFormat.JPEG, 90, s); + s.flush(); } /** @@ -834,6 +837,7 @@ public class ExifInterface { } OutputStream s = getExifWriterStream(exifOutStream); doExifStreamIO(jpegStream, s); + s.flush(); } /** @@ -1010,7 +1014,7 @@ public class ExifInterface { boolean ret; try { File temp = new File(filename); - is = new FileInputStream(temp); + is = new BufferedInputStream(new FileInputStream(temp)); // Parse beginning of APP1 in exif to find size of exif header. ExifParser parser = null; diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java index 38b34fc6c..ae501a50f 100644 --- a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java +++ b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java @@ -18,6 +18,7 @@ package com.android.gallery3d.exif; import android.util.Log; +import java.io.BufferedOutputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -58,6 +59,7 @@ import java.nio.ByteOrder; class ExifOutputStream extends FilterOutputStream { private static final String TAG = "ExifOutputStream"; private static final boolean DEBUG = false; + private static final int STREAMBUFFER_SIZE = 0x00010000; // 64Kb private static final int STATE_SOI = 0; private static final int STATE_FRAME_HEADER = 1; @@ -80,7 +82,7 @@ class ExifOutputStream extends FilterOutputStream { private final ExifInterface mInterface; protected ExifOutputStream(OutputStream ou, ExifInterface iRef) { - super(ou); + super(new BufferedOutputStream(ou, STREAMBUFFER_SIZE)); mInterface = iRef; } |