summaryrefslogtreecommitdiffstats
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
commitbc6773761fa669f6090b8a1f9a08d9283b94a2ed (patch)
treeb70987db2ca5b2f9cb5e8bb294b235411f0c0c8b
parent1927ec5dc5ae1d202f6a0e2a55a2e8d834f6ce60 (diff)
downloadandroid_packages_apps_Snap-bc6773761fa669f6090b8a1f9a08d9283b94a2ed.zip
android_packages_apps_Snap-bc6773761fa669f6090b8a1f9a08d9283b94a2ed.tar.gz
android_packages_apps_Snap-bc6773761fa669f6090b8a1f9a08d9283b94a2ed.tar.bz2
Do not use UTF-8 to decode string in ExifOutputStream
Change-Id: Id0303a9e8a72db1625e8d0f7487be44227b0ce6a
-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 b8db8e3..e5e7760 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;