summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorAlok Kediya <kediya@codeaurora.org>2013-09-28 17:12:35 +0530
committerLinux Build Service Account <lnxbuild@localhost>2013-10-31 19:39:35 -0600
commitd8887ed7c40a161431c6b4db32dddcb46859692f (patch)
treeb1063bba921681c8a0894c423abbb200accdc5c7 /src/com/android
parent28c3196d6ecc29322d15b0f6f46ceba8af2244ac (diff)
downloadandroid_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')
-rw-r--r--src/com/android/camera/CameraSettings.java15
-rw-r--r--src/com/android/camera/MediaSaveService.java17
-rw-r--r--src/com/android/camera/PhotoModule.java18
-rw-r--r--src/com/android/camera/Storage.java32
-rw-r--r--src/com/android/camera/VideoModule.java9
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java8
-rw-r--r--src/com/android/camera/tinyplanet/TinyPlanetFragment.java3
7 files changed, 75 insertions, 27 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 7d90a0689..4e824775b 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -104,6 +104,7 @@ public class CameraSettings {
private static final String KEY_QC_SUPPORTED_FACE_RECOGNITION_MODES = "face-recognition-values";
public static final String KEY_QC_AE_BRACKETING = "ae-bracket-hdr";
public static final String KEY_QC_FACE_RECOGNITION = "face-recognition";
+ private static final String KEY_QC_PICTURE_FORMAT = "picture-format-values";
private static final String VIDEO_QUALITY_HIGH = "high";
private static final String VIDEO_QUALITY_MMS = "mms";
private static final String VIDEO_QUALITY_YOUTUBE = "youtube";
@@ -231,6 +232,13 @@ public class CameraSettings {
}
return substrings;
}
+ private List<String> getSupportedPictureFormatLists() {
+ String str = mParameters.get(KEY_QC_PICTURE_FORMAT);
+ if (str == null) {
+ str = "jpeg,raw"; // if not set, fall back to default behavior
+ }
+ return split(str);
+ }
private void qcomInitPreferences(PreferenceGroup group){
//Qcom Preference add here
ListPreference powerMode = group.findPreference(KEY_POWER_MODE);
@@ -254,7 +262,7 @@ public class CameraSettings {
ListPreference jpegQuality = group.findPreference(KEY_JPEG_QUALITY);
ListPreference videoSnapSize = group.findPreference(KEY_VIDEO_SNAPSHOT_SIZE);
ListPreference videoHdr = group.findPreference(KEY_VIDEO_HDR);
-
+ ListPreference pictureFormat = group.findPreference(KEY_PICTURE_FORMAT);
if (touchAfAec != null) {
filterUnsupportedOptions(group,
@@ -324,6 +332,11 @@ public class CameraSettings {
histogram, mParameters.getSupportedHistogramModes());
}
+ if (pictureFormat!= null) {
+ filterUnsupportedOptions(group,
+ pictureFormat, getSupportedPictureFormatLists());
+ }
+
}
private void initPreference(PreferenceGroup group) {
ListPreference videoQuality = group.findPreference(KEY_VIDEO_QUALITY);
diff --git a/src/com/android/camera/MediaSaveService.java b/src/com/android/camera/MediaSaveService.java
index e8ec08d57..7761f7f4c 100644
--- a/src/com/android/camera/MediaSaveService.java
+++ b/src/com/android/camera/MediaSaveService.java
@@ -28,7 +28,7 @@ import android.os.Binder;
import android.os.IBinder;
import android.provider.MediaStore.Video;
import android.util.Log;
-
+import com.android.camera.PhotoModule;
import com.android.camera.exif.ExifInterface;
import java.io.File;
@@ -87,14 +87,14 @@ public class MediaSaveService extends Service {
public void addImage(final byte[] data, String title, long date, Location loc,
int width, int height, int orientation, ExifInterface exif,
- OnMediaSavedListener l, ContentResolver resolver) {
+ OnMediaSavedListener l, ContentResolver resolver, String pictureFormat) {
if (isQueueFull()) {
Log.e(TAG, "Cannot add image when the queue is full");
return;
}
ImageSaveTask t = new ImageSaveTask(data, title, date,
(loc == null) ? null : new Location(loc),
- width, height, orientation, exif, resolver, l);
+ width, height, orientation, exif, resolver, l, pictureFormat);
mMemoryUse += data.length;
if (isQueueFull()) {
@@ -108,13 +108,14 @@ public class MediaSaveService extends Service {
OnMediaSavedListener l, ContentResolver resolver) {
// When dimensions are unknown, pass 0 as width and height,
// and decode image for width and height later in a background thread
- addImage(data, title, date, loc, 0, 0, orientation, exif, l, resolver);
+ addImage(data, title, date, loc, 0, 0, orientation, exif, l, resolver,
+ PhotoModule.PIXEL_FORMAT_JPEG);
}
public void addImage(final byte[] data, String title, Location loc,
int width, int height, int orientation, ExifInterface exif,
OnMediaSavedListener l, ContentResolver resolver) {
addImage(data, title, System.currentTimeMillis(), loc, width, height,
- orientation, exif, l, resolver);
+ orientation, exif, l, resolver,PhotoModule.PIXEL_FORMAT_JPEG);
}
public void addVideo(String path, long duration, ContentValues values,
@@ -148,10 +149,11 @@ public class MediaSaveService extends Service {
private ExifInterface exif;
private ContentResolver resolver;
private OnMediaSavedListener listener;
+ private String pictureFormat;
public ImageSaveTask(byte[] data, String title, long date, Location loc,
int width, int height, int orientation, ExifInterface exif,
- ContentResolver resolver, OnMediaSavedListener listener) {
+ ContentResolver resolver, OnMediaSavedListener listener, String pictureFormat) {
this.data = data;
this.title = title;
this.date = date;
@@ -162,6 +164,7 @@ public class MediaSaveService extends Service {
this.exif = exif;
this.resolver = resolver;
this.listener = listener;
+ this.pictureFormat = pictureFormat;
}
@Override
@@ -180,7 +183,7 @@ public class MediaSaveService extends Service {
height = options.outHeight;
}
return Storage.addImage(
- resolver, title, date, loc, orientation, exif, data, width, height);
+ resolver, title, date, loc, orientation, exif, data, width, height, pictureFormat);
}
@Override
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 461847b18..fa618a483 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -192,7 +192,7 @@ public class PhotoModule
// Constant from android.hardware.Camera.Parameters
private static final String KEY_PICTURE_FORMAT = "picture-format";
private static final String KEY_QC_RAW_PICUTRE_SIZE = "raw-size";
- private static final String PIXEL_FORMAT_JPEG = "jpeg";
+ public static final String PIXEL_FORMAT_JPEG = "jpeg";
private static final int MIN_SCE_FACTOR = -10;
private static final int MAX_SCE_FACTOR = +10;
@@ -863,6 +863,19 @@ public class PhotoModule
width = s.height;
height = s.width;
}
+
+ String pictureFormat = mParameters.get(KEY_PICTURE_FORMAT);
+ if (pictureFormat != null && !pictureFormat.equalsIgnoreCase(PIXEL_FORMAT_JPEG)) {
+ // overwrite width and height if raw picture
+ String pair = mParameters.get(KEY_QC_RAW_PICUTRE_SIZE);
+ if (pair != null) {
+ int pos = pair.indexOf('x');
+ if (pos != -1) {
+ width = Integer.parseInt(pair.substring(0, pos));
+ height = Integer.parseInt(pair.substring(pos + 1));
+ }
+ }
+ }
NamedEntity name = mNamedImages.getNextNameEntity();
String title = (name == null) ? null : name.title;
long date = (name == null) ? -1 : name.date;
@@ -893,9 +906,10 @@ public class PhotoModule
exif.setTag(directionRefTag);
exif.setTag(directionTag);
}
+ String mPictureFormat = mParameters.get(KEY_PICTURE_FORMAT);
mActivity.getMediaSaveService().addImage(
jpegData, title, date, mLocation, width, height,
- orientation, exif, mOnMediaSavedListener, mContentResolver);
+ orientation, exif, mOnMediaSavedListener, mContentResolver, mPictureFormat);
}
// Animate capture with real jpeg data instead of a preview frame.
mUI.animateCapture(jpegData, orientation, mMirror);
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() {
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 28ee4ced3..e0d3a72ba 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -65,7 +65,7 @@ import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
import com.android.camera2.R;
-
+import com.android.camera.PhotoModule;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
@@ -1962,10 +1962,11 @@ public class VideoModule implements CameraModule,
String title = CameraUtil.createJpegName(dateTaken);
ExifInterface exif = Exif.getExif(data);
int orientation = Exif.getOrientation(exif);
-
+ Size s = mParameters.getPictureSize();
mActivity.getMediaSaveService().addImage(
- data, title, dateTaken, loc, orientation,
- exif, mOnPhotoSavedListener, mContentResolver);
+ data, title, dateTaken, loc, s.width, s.height, orientation,
+ exif, mOnPhotoSavedListener, mContentResolver,
+ PhotoModule.PIXEL_FORMAT_JPEG);
}
private String convertOutputFormatToMimeType(int outputFileFormat) {
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index ad0b8a262..6f872ea07 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -43,7 +43,7 @@ import android.view.OrientationEventListener;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
-
+import com.android.camera.PhotoModule;
import com.android.camera.CameraManager.CameraProxy;
import com.android.camera.app.OrientationManager;
import com.android.camera.exif.ExifInterface;
@@ -742,7 +742,8 @@ public class WideAnglePanoramaModule
if (jpegData != null) {
String filename = PanoUtil.createName(
mActivity.getResources().getString(R.string.pano_file_name_format), mTimeTaken);
- String filepath = Storage.generateFilepath(filename);
+ String filepath = Storage.generateFilepath(filename,
+ PhotoModule.PIXEL_FORMAT_JPEG);
Location loc = mLocationManager.getCurrentLocation();
ExifInterface exif = new ExifInterface();
@@ -761,7 +762,8 @@ public class WideAnglePanoramaModule
}
int jpegLength = (int) (new File(filepath).length());
return Storage.addImage(mContentResolver, filename, mTimeTaken,
- loc, orientation, jpegLength, filepath, width, height);
+ loc, orientation, jpegLength, filepath, width, height,
+ PhotoModule.PIXEL_FORMAT_JPEG);
}
return null;
}
diff --git a/src/com/android/camera/tinyplanet/TinyPlanetFragment.java b/src/com/android/camera/tinyplanet/TinyPlanetFragment.java
index 9cde87b16..d1d5af91c 100644
--- a/src/com/android/camera/tinyplanet/TinyPlanetFragment.java
+++ b/src/com/android/camera/tinyplanet/TinyPlanetFragment.java
@@ -43,6 +43,7 @@ import com.adobe.xmp.XMPException;
import com.adobe.xmp.XMPMeta;
import com.android.camera.CameraActivity;
import com.android.camera.MediaSaveService;
+import com.android.camera.PhotoModule;
import com.android.camera.MediaSaveService.OnMediaSavedListener;
import com.android.camera.exif.ExifInterface;
import com.android.camera.tinyplanet.TinyPlanetPreview.PreviewSizeListener;
@@ -321,7 +322,7 @@ public class TinyPlanetFragment extends DialogFragment implements PreviewSizeLis
mediaSaveService.addImage(image.mJpegData, tinyPlanetTitle, (new Date()).getTime(),
null,
image.mSize, image.mSize, 0, null, doneListener, getActivity()
- .getContentResolver());
+ .getContentResolver(),PhotoModule.PIXEL_FORMAT_JPEG);
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}