summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com/android/gallery3d/exif
diff options
context:
space:
mode:
authorEarl Ou <shunhsingou@google.com>2012-10-18 19:14:16 +0800
committerEarl Ou <shunhsingou@google.com>2012-10-31 10:14:06 +0800
commit4bc57f24b4ed268fdb5f0b67d3bc39f6a449b2f4 (patch)
treef894413cb59603d5a2a8492bc68d131afa8b17ee /gallerycommon/src/com/android/gallery3d/exif
parent7e92ec75da5e2eb06e659e2226f64749b80ea3d9 (diff)
downloadandroid_packages_apps_Snap-4bc57f24b4ed268fdb5f0b67d3bc39f6a449b2f4.tar.gz
android_packages_apps_Snap-4bc57f24b4ed268fdb5f0b67d3bc39f6a449b2f4.tar.bz2
android_packages_apps_Snap-4bc57f24b4ed268fdb5f0b67d3bc39f6a449b2f4.zip
Do not use UTF-8 to decode string in ExifOutputStream
Change-Id: Id0303a9e8a72db1625e8d0f7487be44227b0ce6a
Diffstat (limited to 'gallerycommon/src/com/android/gallery3d/exif')
-rw-r--r--gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java
index b8db8e34c..e5e776098 100644
--- a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java
+++ b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.nio.charset.Charset;
public class ExifOutputStream extends FilterOutputStream {
private static final String TAG = "ExifOutputStream";
@@ -215,9 +216,12 @@ public class ExifOutputStream extends FilterOutputStream {
throws IOException {
switch (tag.getDataType()) {
case ExifTag.TYPE_ASCII:
- dataOutputStream.write(tag.getString().getBytes());
- int remain = tag.getComponentCount() - tag.getString().length();
- for (int i = 0; i < remain; i++) {
+ byte buf[] = tag.getString().getBytes(Charset.forName("US-ASCII"));
+ if (buf.length == tag.getComponentCount()) {
+ buf[buf.length - 1] = 0;
+ dataOutputStream.write(buf);
+ } else {
+ dataOutputStream.write(buf);
dataOutputStream.write(0);
}
break;
@@ -234,7 +238,7 @@ public class ExifOutputStream extends FilterOutputStream {
break;
case ExifTag.TYPE_UNDEFINED:
case ExifTag.TYPE_UNSIGNED_BYTE:
- byte[] buf = new byte[tag.getComponentCount()];
+ buf = new byte[tag.getComponentCount()];
tag.getBytes(buf);
dataOutputStream.write(buf);
break;