diff options
author | Likai Ding <likaid@codeaurora.org> | 2014-09-29 11:32:02 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-11-11 07:18:20 -0800 |
commit | 291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82 (patch) | |
tree | 6d532843046f0d99330d33fb748b3e072e2e7bea /src/com/android/camera/exif/ExifOutputStream.java | |
parent | 52f4cda298a5d53395fc46959c88f94b2d3fe921 (diff) | |
download | android_packages_apps_Snap-291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82.tar.gz android_packages_apps_Snap-291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82.tar.bz2 android_packages_apps_Snap-291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82.zip |
Camera2: correct image size recorded in media provider db
Photos taken in camcorder can't be previewed on PC via MTP mode. The
root cause is that, the actual image file size does not always match
the _size column in media provider database. During the saving process,
EXIF data are rewritten, but the size sent to media provider is not
updated accordingly.
Record bytes written in ExifOutputStream and OrderedDataOutputStream so
that after rewritting, the correct image size could be sent to media
provider.
Change-Id: I74d91e86d712c121eb50daecaf879ab4f5be97fc
CRs-Fixed: 711522
Diffstat (limited to 'src/com/android/camera/exif/ExifOutputStream.java')
-rw-r--r-- | src/com/android/camera/exif/ExifOutputStream.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/com/android/camera/exif/ExifOutputStream.java b/src/com/android/camera/exif/ExifOutputStream.java index 191e8280c..90d432769 100644 --- a/src/com/android/camera/exif/ExifOutputStream.java +++ b/src/com/android/camera/exif/ExifOutputStream.java @@ -82,6 +82,8 @@ class ExifOutputStream extends FilterOutputStream { private ByteBuffer mBuffer = ByteBuffer.allocate(4); private final ExifInterface mInterface; + private int mSize = 0; + protected ExifOutputStream(OutputStream ou, ExifInterface iRef) { super(new BufferedOutputStream(ou, STREAMBUFFER_SIZE)); mInterface = iRef; @@ -127,6 +129,7 @@ class ExifOutputStream extends FilterOutputStream { if (mByteToCopy > 0) { int byteToProcess = length > mByteToCopy ? mByteToCopy : length; out.write(buffer, offset, byteToProcess); + mSize += byteToProcess; length -= byteToProcess; mByteToCopy -= byteToProcess; offset += byteToProcess; @@ -147,6 +150,7 @@ class ExifOutputStream extends FilterOutputStream { throw new IOException("Not a valid jpeg image, cannot write exif"); } out.write(mBuffer.array(), 0, 2); + mSize += 2; mState = STATE_FRAME_HEADER; mBuffer.rewind(); writeExifData(); @@ -162,6 +166,7 @@ class ExifOutputStream extends FilterOutputStream { short tag = mBuffer.getShort(); if (tag == JpegHeader.EOI) { out.write(mBuffer.array(), 0, 2); + mSize += 2; mBuffer.rewind(); } } @@ -175,9 +180,11 @@ class ExifOutputStream extends FilterOutputStream { mState = STATE_JPEG_DATA; } else if (!JpegHeader.isSofMarker(marker)) { out.write(mBuffer.array(), 0, 4); + mSize += 4; mByteToCopy = (mBuffer.getShort() & 0x0000ffff) - 2; } else { out.write(mBuffer.array(), 0, 4); + mSize += 4; mState = STATE_JPEG_DATA; } mBuffer.rewind(); @@ -185,6 +192,7 @@ class ExifOutputStream extends FilterOutputStream { } if (length > 0) { out.write(buffer, offset, length); + mSize += length; } } @@ -238,6 +246,7 @@ class ExifOutputStream extends FilterOutputStream { for (ExifTag t : nullTags) { mExifData.addTag(t); } + mSize += dataOutputStream.size(); } private ArrayList<ExifTag> stripNullValueTags(ExifData data) { @@ -515,4 +524,8 @@ class ExifOutputStream extends FilterOutputStream { break; } } + + int size() { + return mSize; + } } |