From: Baligh Uddin Date: Tue, 22 Oct 2013 19:55:25 +0000 (+0000) Subject: Merge "Import translations. DO NOT MERGE" X-Git-Tag: android-x86-7.1-r1~202 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=017fe2adf1f6ec8ef3253dbcd00ae51470735f86;hp=c262bd8ac9ebe0cfa7d6cd4855a47bd45f28d242;p=android-x86%2Fpackages-apps-Gallery2.git Merge "Import translations. DO NOT MERGE" --- diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java index 69edd6051..52c296c78 100644 --- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java +++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java @@ -129,36 +129,52 @@ public final class ImageLoader { } finally { Utils.closeSilently(cursor); } - - // Fall back to checking EXIF tags in file. - if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { - String mimeType = getMimeType(uri); - if (!JPEG_MIME_TYPE.equals(mimeType)) { - return ORI_NORMAL; + ExifInterface exif = new ExifInterface(); + InputStream is = null; + // Fall back to checking EXIF tags in file or input stream. + try { + if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { + String mimeType = getMimeType(uri); + if (!JPEG_MIME_TYPE.equals(mimeType)) { + return ORI_NORMAL; + } + String path = uri.getPath(); + exif.readExif(path); + } else { + is = context.getContentResolver().openInputStream(uri); + exif.readExif(is); } - String path = uri.getPath(); - ExifInterface exif = new ExifInterface(); + return parseExif(exif); + } catch (IOException e) { + Log.w(LOGTAG, "Failed to read EXIF orientation", e); + } finally { try { - exif.readExif(path); - Integer tagval = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION); - if (tagval != null) { - int orientation = tagval; - switch(orientation) { - case ORI_NORMAL: - case ORI_ROTATE_90: - case ORI_ROTATE_180: - case ORI_ROTATE_270: - case ORI_FLIP_HOR: - case ORI_FLIP_VERT: - case ORI_TRANSPOSE: - case ORI_TRANSVERSE: - return orientation; - default: - return ORI_NORMAL; - } + if (is != null) { + is.close(); } } catch (IOException e) { - Log.w(LOGTAG, "Failed to read EXIF orientation", e); + Log.w(LOGTAG, "Failed to close InputStream", e); + } + } + return ORI_NORMAL; + } + + private static int parseExif(ExifInterface exif){ + Integer tagval = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION); + if (tagval != null) { + int orientation = tagval; + switch(orientation) { + case ORI_NORMAL: + case ORI_ROTATE_90: + case ORI_ROTATE_180: + case ORI_ROTATE_270: + case ORI_FLIP_HOR: + case ORI_FLIP_VERT: + case ORI_TRANSPOSE: + case ORI_TRANSVERSE: + return orientation; + default: + return ORI_NORMAL; } } return ORI_NORMAL; diff --git a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java index 4322ed700..4765a5990 100644 --- a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java @@ -394,7 +394,7 @@ public class ImagePreset { break; } } - if (!replaced) { + if (!replaced && !isNoneFxFilter(representation)) { mFilters.add(0, representation); } } else { diff --git a/src/com/android/gallery3d/filtershow/tools/SaveImage.java b/src/com/android/gallery3d/filtershow/tools/SaveImage.java index 354081ed2..c3cdea8df 100644 --- a/src/com/android/gallery3d/filtershow/tools/SaveImage.java +++ b/src/com/android/gallery3d/filtershow/tools/SaveImage.java @@ -402,6 +402,10 @@ public class SaveImage { // if we have a valid size int w = (int) (bitmap.getWidth() * sizeFactor); int h = (int) (bitmap.getHeight() * sizeFactor); + if (w == 0 || h == 0) { + w = 1; + h = 1; + } bitmap = Bitmap.createScaledBitmap(bitmap, w, h, true); } updateProgress(); diff --git a/src/com/android/gallery3d/filtershow/ui/ExportDialog.java b/src/com/android/gallery3d/filtershow/ui/ExportDialog.java index f6a84cee2..b42c9f367 100644 --- a/src/com/android/gallery3d/filtershow/ui/ExportDialog.java +++ b/src/com/android/gallery3d/filtershow/ui/ExportDialog.java @@ -202,8 +202,8 @@ public class ExportDialog extends DialogFragment implements View.OnClickListener return; } mEditing = true; - int width = 0; - int height = 0; + int width = 1; + int height = 1; if (text.getId() == R.id.editableWidth) { if (mWidthText.getText() != null) { String value = String.valueOf(mWidthText.getText()); @@ -213,6 +213,10 @@ public class ExportDialog extends DialogFragment implements View.OnClickListener width = mOriginalBounds.width(); mWidthText.setText("" + width); } + if (width <= 0) { + width = (int) Math.ceil(mRatio); + mWidthText.setText("" + width); + } height = (int) (width / mRatio); } mHeightText.setText("" + height); @@ -226,6 +230,10 @@ public class ExportDialog extends DialogFragment implements View.OnClickListener height = mOriginalBounds.height(); mHeightText.setText("" + height); } + if (height <= 0) { + height = 1; + mHeightText.setText("" + height); + } width = (int) (height * mRatio); } mWidthText.setText("" + width);