diff options
author | Alok Kediya <kediya@codeaurora.org> | 2013-09-28 17:12:35 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2013-10-31 19:39:35 -0600 |
commit | d8887ed7c40a161431c6b4db32dddcb46859692f (patch) | |
tree | b1063bba921681c8a0894c423abbb200accdc5c7 /src/com/android/camera/Storage.java | |
parent | 28c3196d6ecc29322d15b0f6f46ceba8af2244ac (diff) | |
download | android_packages_apps_Snap-d8887ed7c40a161431c6b4db32dddcb46859692f.tar.gz android_packages_apps_Snap-d8887ed7c40a161431c6b4db32dddcb46859692f.tar.bz2 android_packages_apps_Snap-d8887ed7c40a161431c6b4db32dddcb46859692f.zip |
Camera: Add support for raw snapshot
Previously picture format only have option for jpeg and raw,
but detailed raw image format is misssing from menu to choose.
Also, changes to save raw image to coorect path
are included.
(cherrypicked from commit c0028f9dbe178c3fed1bcb4af96eb0db4d2e2973)
Change-Id: Ifab7fd80e4a83370b2dc6932340005a06cc3552f
(cherry picked from commit 27f9245f35d0284c17d8d2fdf5576ea3879e7d33)
(cherry picked from commit 3c66703af119c06697f16303fadadbe956646cb3)
Diffstat (limited to 'src/com/android/camera/Storage.java')
-rw-r--r-- | src/com/android/camera/Storage.java | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java index a8ce08b93..00bd8d1c4 100644 --- a/src/com/android/camera/Storage.java +++ b/src/com/android/camera/Storage.java @@ -43,6 +43,7 @@ public class Storage { Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString(); public static final String DIRECTORY = DCIM + "/Camera"; + public static final String RAW_DIRECTORY = DCIM + "/Camera/raw"; // Match the code in MediaProvider.computeBucketValues(). public static final String BUCKET_ID = @@ -80,32 +81,41 @@ public class Storage { // Save the image and add it to media store. public static Uri addImage(ContentResolver resolver, String title, long date, Location location, int orientation, ExifInterface exif, - byte[] jpeg, int width, int height) { + byte[] jpeg, int width, int height, String pictureFormat) { // Save the image. - String path = generateFilepath(title); - if (exif != null) { + String path = generateFilepath(title, pictureFormat); + if (exif != null && (pictureFormat == null || + pictureFormat.equalsIgnoreCase("jpeg"))) { try { exif.writeExif(jpeg, path); } catch (Exception e) { Log.e(TAG, "Failed to write data", e); } } else { + if (!(pictureFormat.equalsIgnoreCase("jpeg") || pictureFormat == null)) { + File dir = new File(RAW_DIRECTORY); + dir.mkdirs(); + } writeFile(path, jpeg); } return addImage(resolver, title, date, location, orientation, - jpeg.length, path, width, height); + jpeg.length, path, width, height, pictureFormat); } // Add the image to media store. public static Uri addImage(ContentResolver resolver, String title, long date, Location location, int orientation, int jpegLength, - String path, int width, int height) { + String path, int width, int height, String pictureFormat) { // Insert into MediaStore. ContentValues values = new ContentValues(9); values.put(ImageColumns.TITLE, title); - values.put(ImageColumns.DISPLAY_NAME, title + ".jpg"); + if (pictureFormat.equalsIgnoreCase("jpeg") || pictureFormat == null) { + values.put(ImageColumns.DISPLAY_NAME, title + ".jpg"); + } else { + values.put(ImageColumns.DISPLAY_NAME, title + ".raw"); + } values.put(ImageColumns.DATE_TAKEN, date); - values.put(ImageColumns.MIME_TYPE, LocalData.MIME_TYPE_JPEG); + values.put(ImageColumns.MIME_TYPE, "image/jpeg"); // Clockwise rotation in degrees. 0, 90, 180, or 270. values.put(ImageColumns.ORIENTATION, orientation); values.put(ImageColumns.DATA, path); @@ -140,8 +150,12 @@ public class Storage { } } - public static String generateFilepath(String title) { - return DIRECTORY + '/' + title + ".jpg"; + public static String generateFilepath(String title, String pictureFormat) { + if (pictureFormat.equalsIgnoreCase("jpeg") || pictureFormat == null) { + return DIRECTORY + '/' + title + ".jpg"; + } else { + return RAW_DIRECTORY + '/' + title + ".raw"; + } } public static long getAvailableSpace() { |