public class JpegImageBackendImageSaver implements ImageSaver.Builder {
private static Log.Tag TAG = new Log.Tag("JpegImgBESaver");
+ /** Factor to downsample full-size JPEG image for use in thumbnail bitmap. */
+ private static final int JPEG_DOWNSAMPLE_FOR_FAST_INDICATOR = 4;
+
@ParametersAreNonnullByDefault
private static class ImageSaverImpl implements SingleImageSaver {
private final MainThread mExecutor;
TaskImageContainer.CompressedPayload payload) {
if (task.destination == TaskImageContainer.TaskInfo.Destination.FINAL_IMAGE) {
// Just start the thumbnail now, since there's no earlier event.
+
+ // Downsample and convert the JPEG payload to a reasonably-sized Bitmap
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inSampleSize = JPEG_DOWNSAMPLE_FOR_FAST_INDICATOR;
final Bitmap bitmap = BitmapFactory.decodeByteArray(payload.data, 0,
- payload.data.length);
+ payload.data.length, options);
+
// If the rotation is implemented as an EXIF flag, we need to
// pass this information onto the UI call, since the rotation is
// NOT applied to the bitmap directly.
import com.android.camera.app.MediaSaver;
import com.android.camera.app.OrientationManager;
import com.android.camera.app.OrientationManager.DeviceOrientation;
-import com.android.camera.debug.Log;
import com.android.camera.exif.ExifInterface;
import com.android.camera.one.v2.camera2proxy.ImageProxy;
import com.android.camera.session.CaptureSession;
/**
* Wraps static call to Exif for testability.
- * @param jpegData Binary data of the JPEG with EXIF flags
*
+ * @param jpegData Binary data of the JPEG with EXIF flags
* @return Degrees of rotation of the EXIF flag
*/
- public int exifGetOrientation(byte [] jpegData) {
+ public int exifGetOrientation(byte[] jpegData) {
return Exif.getOrientation(jpegData);
}
// doesn't work on direct buffers. So, we make a local
// copy in a non-direct buffer.
ByteBuffer origBuffer = img.proxy.getPlanes().get(0).getBuffer();
- compressedData = ByteBuffer.allocate(origBuffer.capacity());
+ compressedData = ByteBuffer.allocate(origBuffer.limit());
origBuffer.rewind();
compressedData.put(origBuffer);
origBuffer.rewind();
onStart(mId, inputImage, resultImage, TaskInfo.Destination.FINAL_IMAGE);
- numBytes = compressedData.capacity();
+ numBytes = compressedData.limit();
break;
case ImageFormat.YUV_420_888:
try {
*/
protected ExifInterface createExif(TaskImage image) {
ExifInterface exif = new ExifInterface();
- exif.setTag(exif.buildTag(ExifInterface.TAG_PIXEL_X_DIMENSION, image.width));
- exif.setTag(exif.buildTag(ExifInterface.TAG_PIXEL_Y_DIMENSION, image.height));
+ exif.setTag(exif.buildTag(ExifInterface.TAG_IMAGE_WIDTH, image.width));
+ exif.setTag(exif.buildTag(ExifInterface.TAG_IMAGE_LENGTH, image.height));
exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION,
ExifInterface.getOrientationValueForRotation(image.orientation.getDegrees())));
return exif;