diff options
Diffstat (limited to 'gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java')
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java index b8db8e34c..51a30ffa2 100644 --- a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java +++ b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java @@ -215,15 +215,19 @@ 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.getStringByte(); + if (buf.length == tag.getComponentCount()) { + buf[buf.length - 1] = 0; + dataOutputStream.write(buf); + } else { + dataOutputStream.write(buf); dataOutputStream.write(0); } break; case ExifTag.TYPE_LONG: + case ExifTag.TYPE_UNSIGNED_LONG: for (int i = 0, n = tag.getComponentCount(); i < n; i++) { - dataOutputStream.writeInt(tag.getLong(i)); + dataOutputStream.writeInt((int) tag.getValueAt(i)); } break; case ExifTag.TYPE_RATIONAL: @@ -234,18 +238,13 @@ 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; - case ExifTag.TYPE_UNSIGNED_LONG: - for (int i = 0, n = tag.getComponentCount(); i < n; i++) { - dataOutputStream.writeInt((int) tag.getUnsignedLong(i)); - } - break; case ExifTag.TYPE_UNSIGNED_SHORT: for (int i = 0, n = tag.getComponentCount(); i < n; i++) { - dataOutputStream.writeShort((short) tag.getUnsignedShort(i)); + dataOutputStream.writeShort((short) tag.getValueAt(i)); } break; } |