Loading src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java +10 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,16 @@ public class ImagePreset { return false; } public boolean contains(byte type) { for (FilterRepresentation representation : mFilters) { if (representation.getFilterType() == type && !representation.isNil()) { return true; } } return false; } public boolean isPanoramaSafe() { for (FilterRepresentation representation : mFilters) { if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY Loading src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public class ImageSavingTask extends ProcessingTask { postUpdate(updateProgress); } }); Uri uri = saveImage.processAndSaveImage(preset, !flatten, Uri uri = saveImage.processAndSaveImage(preset, flatten, request.quality, request.sizeFactor); URIResult result = new URIResult(); result.uri = uri; Loading src/com/android/gallery3d/filtershow/tools/SaveImage.java +63 −38 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.gallery3d.common.Utils; import com.android.gallery3d.exif.ExifInterface; import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.filters.FiltersManager; import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.pipeline.CachingPipeline; Loading Loading @@ -314,10 +315,20 @@ public class SaveImage { } } public Uri processAndSaveImage(ImagePreset preset, boolean doAuxBackup, private void updateExifData(ExifInterface exif, long time) { // Set tags exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time, TimeZone.getDefault()); exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION, ExifInterface.Orientation.TOP_LEFT)); // Remove old thumbnail exif.removeCompressedThumbnail(); } public Uri processAndSaveImage(ImagePreset preset, boolean flatten, int quality, float sizeFactor) { Uri uri = resetToOriginalImageIfNeeded(preset, doAuxBackup); Uri uri = resetToOriginalImageIfNeeded(preset, !flatten); if (uri != null) { return null; } Loading @@ -332,33 +343,44 @@ public class SaveImage { // newSourceUri is then pointing to the new location. // If no file is moved, newSourceUri will be the same as mSourceUri. Uri newSourceUri = mSourceUri; if (doAuxBackup) { if (!flatten) { newSourceUri = moveSrcToAuxIfNeeded(mSourceUri, mDestinationFile); } Uri savedUri = mSelectedImageUri; if (mPreviewImage != null) { if (flatten) { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); // Set tags long time = System.currentTimeMillis(); exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time, TimeZone.getDefault()); exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION, ExifInterface.Orientation.TOP_LEFT)); // Remove old thumbnail exif.removeCompressedThumbnail(); updateExifData(exif, time); if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) { putPanoramaXMPData(mDestinationFile, xmp); ContentValues values = getContentValues(mContext, mSelectedImageUri, mDestinationFile, time); Object result = mContext.getContentResolver().insert( Images.Media.EXTERNAL_CONTENT_URI, values); } } else { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); long time = System.currentTimeMillis(); updateExifData(exif, time); // If we succeed in writing the bitmap as a jpeg, return a uri. if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) { putPanoramaXMPData(mDestinationFile, xmp); // mDestinationFile will save the newSourceUri info in the XMP. if (!flatten) { XmpPresets.writeFilterXMP(mContext, newSourceUri, mDestinationFile, preset); } // After this call, mSelectedImageUri will be actually // pointing at the new file mDestinationFile. savedUri = SaveImage.linkNewFileToUri(mContext, mSelectedImageUri, mDestinationFile, time, doAuxBackup); mDestinationFile, time, !flatten); } } } Loading Loading @@ -387,27 +409,27 @@ public class SaveImage { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); updateProgress(); // Set tags long time = System.currentTimeMillis(); exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time, TimeZone.getDefault()); exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION, ExifInterface.Orientation.TOP_LEFT)); // Remove old thumbnail exif.removeCompressedThumbnail(); updateProgress(); updateExifData(exif, time); updateProgress(); // If we succeed in writing the bitmap as a jpeg, return a uri. if (putExifData(mDestinationFile, exif, bitmap, quality)) { putPanoramaXMPData(mDestinationFile, xmp); // mDestinationFile will save the newSourceUri info in the XMP. if (!flatten) { XmpPresets.writeFilterXMP(mContext, newSourceUri, mDestinationFile, preset); uri = updateFile(mContext, savedUri, mDestinationFile, time); } else { ContentValues values = getContentValues(mContext, mSelectedImageUri, mDestinationFile, time); Object result = mContext.getContentResolver().insert( Images.Media.EXTERNAL_CONTENT_URI, values); } } updateProgress(); Loading Loading @@ -508,9 +530,12 @@ public class SaveImage { File destination) { Uri selectedImageUri = filterShowActivity.getSelectedImageUri(); Uri sourceImageUri = MasterImage.getImage().getUri(); boolean flatten = false; if (preset.contains(FilterRepresentation.TYPE_TINYPLANET)){ flatten = true; } Intent processIntent = ProcessingService.getSaveIntent(filterShowActivity, preset, destination, selectedImageUri, sourceImageUri, false, 90, 1f); destination, selectedImageUri, sourceImageUri, flatten, 90, 1f); filterShowActivity.startService(processIntent); Loading src/com/android/gallery3d/filtershow/ui/ExportDialog.java +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ public class ExportDialog extends DialogFragment implements View.OnClickListener case R.id.done: FilterShowActivity activity = (FilterShowActivity) getActivity(); Uri sourceUri = MasterImage.getImage().getUri(); File dest = SaveImage.getNewFile(activity, sourceUri); File dest = SaveImage.getNewFile(activity, activity.getSelectedImageUri()); float scaleFactor = mExportWidth / (float) mOriginalBounds.width(); Intent processIntent = ProcessingService.getSaveIntent(activity, MasterImage .getImage().getPreset(), dest, activity.getSelectedImageUri(), sourceUri, Loading Loading
src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java +10 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,16 @@ public class ImagePreset { return false; } public boolean contains(byte type) { for (FilterRepresentation representation : mFilters) { if (representation.getFilterType() == type && !representation.isNil()) { return true; } } return false; } public boolean isPanoramaSafe() { for (FilterRepresentation representation : mFilters) { if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY Loading
src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public class ImageSavingTask extends ProcessingTask { postUpdate(updateProgress); } }); Uri uri = saveImage.processAndSaveImage(preset, !flatten, Uri uri = saveImage.processAndSaveImage(preset, flatten, request.quality, request.sizeFactor); URIResult result = new URIResult(); result.uri = uri; Loading
src/com/android/gallery3d/filtershow/tools/SaveImage.java +63 −38 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.gallery3d.common.Utils; import com.android.gallery3d.exif.ExifInterface; import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.filters.FiltersManager; import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.pipeline.CachingPipeline; Loading Loading @@ -314,10 +315,20 @@ public class SaveImage { } } public Uri processAndSaveImage(ImagePreset preset, boolean doAuxBackup, private void updateExifData(ExifInterface exif, long time) { // Set tags exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time, TimeZone.getDefault()); exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION, ExifInterface.Orientation.TOP_LEFT)); // Remove old thumbnail exif.removeCompressedThumbnail(); } public Uri processAndSaveImage(ImagePreset preset, boolean flatten, int quality, float sizeFactor) { Uri uri = resetToOriginalImageIfNeeded(preset, doAuxBackup); Uri uri = resetToOriginalImageIfNeeded(preset, !flatten); if (uri != null) { return null; } Loading @@ -332,33 +343,44 @@ public class SaveImage { // newSourceUri is then pointing to the new location. // If no file is moved, newSourceUri will be the same as mSourceUri. Uri newSourceUri = mSourceUri; if (doAuxBackup) { if (!flatten) { newSourceUri = moveSrcToAuxIfNeeded(mSourceUri, mDestinationFile); } Uri savedUri = mSelectedImageUri; if (mPreviewImage != null) { if (flatten) { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); // Set tags long time = System.currentTimeMillis(); exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time, TimeZone.getDefault()); exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION, ExifInterface.Orientation.TOP_LEFT)); // Remove old thumbnail exif.removeCompressedThumbnail(); updateExifData(exif, time); if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) { putPanoramaXMPData(mDestinationFile, xmp); ContentValues values = getContentValues(mContext, mSelectedImageUri, mDestinationFile, time); Object result = mContext.getContentResolver().insert( Images.Media.EXTERNAL_CONTENT_URI, values); } } else { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); long time = System.currentTimeMillis(); updateExifData(exif, time); // If we succeed in writing the bitmap as a jpeg, return a uri. if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) { putPanoramaXMPData(mDestinationFile, xmp); // mDestinationFile will save the newSourceUri info in the XMP. if (!flatten) { XmpPresets.writeFilterXMP(mContext, newSourceUri, mDestinationFile, preset); } // After this call, mSelectedImageUri will be actually // pointing at the new file mDestinationFile. savedUri = SaveImage.linkNewFileToUri(mContext, mSelectedImageUri, mDestinationFile, time, doAuxBackup); mDestinationFile, time, !flatten); } } } Loading Loading @@ -387,27 +409,27 @@ public class SaveImage { Object xmp = getPanoramaXMPData(newSourceUri, preset); ExifInterface exif = getExifData(newSourceUri); updateProgress(); // Set tags long time = System.currentTimeMillis(); exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time, TimeZone.getDefault()); exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION, ExifInterface.Orientation.TOP_LEFT)); // Remove old thumbnail exif.removeCompressedThumbnail(); updateProgress(); updateExifData(exif, time); updateProgress(); // If we succeed in writing the bitmap as a jpeg, return a uri. if (putExifData(mDestinationFile, exif, bitmap, quality)) { putPanoramaXMPData(mDestinationFile, xmp); // mDestinationFile will save the newSourceUri info in the XMP. if (!flatten) { XmpPresets.writeFilterXMP(mContext, newSourceUri, mDestinationFile, preset); uri = updateFile(mContext, savedUri, mDestinationFile, time); } else { ContentValues values = getContentValues(mContext, mSelectedImageUri, mDestinationFile, time); Object result = mContext.getContentResolver().insert( Images.Media.EXTERNAL_CONTENT_URI, values); } } updateProgress(); Loading Loading @@ -508,9 +530,12 @@ public class SaveImage { File destination) { Uri selectedImageUri = filterShowActivity.getSelectedImageUri(); Uri sourceImageUri = MasterImage.getImage().getUri(); boolean flatten = false; if (preset.contains(FilterRepresentation.TYPE_TINYPLANET)){ flatten = true; } Intent processIntent = ProcessingService.getSaveIntent(filterShowActivity, preset, destination, selectedImageUri, sourceImageUri, false, 90, 1f); destination, selectedImageUri, sourceImageUri, flatten, 90, 1f); filterShowActivity.startService(processIntent); Loading
src/com/android/gallery3d/filtershow/ui/ExportDialog.java +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ public class ExportDialog extends DialogFragment implements View.OnClickListener case R.id.done: FilterShowActivity activity = (FilterShowActivity) getActivity(); Uri sourceUri = MasterImage.getImage().getUri(); File dest = SaveImage.getNewFile(activity, sourceUri); File dest = SaveImage.getNewFile(activity, activity.getSelectedImageUri()); float scaleFactor = mExportWidth / (float) mOriginalBounds.width(); Intent processIntent = ProcessingService.getSaveIntent(activity, MasterImage .getImage().getPreset(), dest, activity.getSelectedImageUri(), sourceUri, Loading