diff options
32 files changed, 141 insertions, 12 deletions
diff --git a/src/com/android/gallery3d/exif/ExifParser.java b/src/com/android/gallery3d/exif/ExifParser.java index 534f2f6d9..f536a55f4 100644 --- a/src/com/android/gallery3d/exif/ExifParser.java +++ b/src/com/android/gallery3d/exif/ExifParser.java @@ -17,6 +17,7 @@ package com.android.gallery3d.exif; import java.io.DataInputStream; +import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.nio.ByteOrder; @@ -27,6 +28,7 @@ public class ExifParser { private static final short SOI = (short) 0xFFD8; // SOI marker of JPEG private static final short APP1 = (short) 0xFFE1; // APP1 marker of JPEG + private static final short APP0 = (short) 0xFFE0; // APP0 marder of JPEG private static final int EXIF_HEADER = 0x45786966; // EXIF header "Exif" private static final short EXIF_HEADER_TAIL = (short) 0x0000; // EXIF header in APP1 @@ -79,7 +81,16 @@ public class ExifParser { throw new ExifInvalidFormatException("Invalid JPEG format"); } - if (dataStream.readShort() != APP1) { + short tag = dataStream.readShort(); + if (tag == APP0) { + int length = dataStream.readUnsignedShort(); + if ((length - 2) != dataStream.skip(length - 2)) { + throw new EOFException(); + } + tag = dataStream.readShort(); + } + + if (tag != APP1) { return false; } diff --git a/src/com/android/gallery3d/exif/IfdParser.java b/src/com/android/gallery3d/exif/IfdParser.java index b0b0bce10..0d1059cb0 100644 --- a/src/com/android/gallery3d/exif/IfdParser.java +++ b/src/com/android/gallery3d/exif/IfdParser.java @@ -125,9 +125,13 @@ public class IfdParser { } public String readString(int n) throws IOException { - byte[] buf = new byte[n]; - mTiffStream.readOrThrow(buf); - return new String(buf, 0, n - 1, "UTF8"); + if (n > 0) { + byte[] buf = new byte[n]; + mTiffStream.readOrThrow(buf); + return new String(buf, 0, n - 1, "UTF8"); + } else { + return ""; + } } public String readString(int n, Charset charset) throws IOException { diff --git a/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java b/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java index d168a787f..b71da1920 100644 --- a/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/AutoFixFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class AutoFixFilter extends AbstractScaleFilter { public static final Creator<AutoFixFilter> CREATOR = creatorOf(AutoFixFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_AUTOFIX); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java b/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java index c5a6a35e4..960be416d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/ColorTemperatureFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -30,6 +32,7 @@ public class ColorTemperatureFilter extends AbstractScaleFilter { ColorTemperatureFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_TEMPERATURE); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/CropFilter.java b/src/com/android/gallery3d/photoeditor/filters/CropFilter.java index 00a6c424a..053998dfb 100644 --- a/src/com/android/gallery3d/photoeditor/filters/CropFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/CropFilter.java @@ -16,11 +16,13 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.graphics.RectF; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -40,6 +42,7 @@ public class CropFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { dst.changeDimension(Math.round(bounds.width() * src.width()), Math.round(bounds.height() * src.height())); diff --git a/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java b/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java index bc233daa2..9c3d49ad9 100644 --- a/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/CrossProcessFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class CrossProcessFilter extends Filter { public static final Creator<CrossProcessFilter> CREATOR = creatorOf(CrossProcessFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_CROSSPROCESS).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java b/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java index d2e4c7cd0..1270defa3 100644 --- a/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/DocumentaryFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class DocumentaryFilter extends Filter { public static final Creator<DocumentaryFilter> CREATOR = creatorOf(DocumentaryFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_DOCUMENTARY).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java b/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java index 61920d377..52e606130 100644 --- a/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/DoodleFilter.java @@ -16,6 +16,7 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; @@ -26,6 +27,7 @@ import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; import com.android.gallery3d.photoeditor.actions.Doodle; @@ -45,6 +47,7 @@ public class DoodleFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Bitmap bitmap = Bitmap.createBitmap(src.width(), src.height(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); diff --git a/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java b/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java index b2c55252e..9449d0925 100644 --- a/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/DuotoneFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -38,6 +40,7 @@ public class DuotoneFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_DUOTONE); effect.setParameter("first_color", firstColor); diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java index b7a1cf1c7..0687e7386 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceTanFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -31,6 +33,7 @@ public class FaceTanFilter extends AbstractScaleFilter { private static final String EFFECT_FACE_TANNING = "com.google.android.media.effect.effects.FaceTanningEffect"; @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EFFECT_FACE_TANNING); effect.setParameter("blend", scale); @@ -42,6 +45,7 @@ public class FaceTanFilter extends AbstractScaleFilter { * * @return boolean true if an effect is present in the system and can be loaded */ + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean isPresent() { return EffectFactory.isEffectSupported(EFFECT_FACE_TANNING); } diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java index 3e4fad206..c714a544e 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -31,6 +33,7 @@ public class FaceliftFilter extends AbstractScaleFilter { private static final String EFFECT_FACELIFT = "com.google.android.media.effect.effects.FaceliftEffect"; @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EFFECT_FACELIFT); effect.setParameter("blend", scale); @@ -42,6 +45,7 @@ public class FaceliftFilter extends AbstractScaleFilter { * * @return boolean true if an effect is present in the system and can be loaded */ + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public static boolean isPresent() { return EffectFactory.isEffectSupported(EFFECT_FACELIFT); } diff --git a/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java b/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java index 3aedd745e..3b128c074 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FillLightFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class FillLightFilter extends AbstractScaleFilter { public static final Creator<FillLightFilter> CREATOR = creatorOf(FillLightFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_FILLLIGHT); effect.setParameter("strength", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/Filter.java b/src/com/android/gallery3d/photoeditor/filters/Filter.java index 5d1ac229b..4304caf68 100644 --- a/src/com/android/gallery3d/photoeditor/filters/Filter.java +++ b/src/com/android/gallery3d/photoeditor/filters/Filter.java @@ -16,11 +16,13 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectContext; import android.os.Parcel; import android.os.Parcelable; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; import java.util.HashMap; @@ -28,6 +30,7 @@ import java.util.HashMap; /** * Image filter for photo editing; all of its methods must be called from a single GL thread. */ +@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public abstract class Filter implements Parcelable { // TODO: This should be set in MFF instead. diff --git a/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java b/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java index 7fe6108c9..3789b39c9 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FisheyeFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class FisheyeFilter extends AbstractScaleFilter { public static final Creator<FisheyeFilter> CREATOR = creatorOf(FisheyeFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_FISHEYE); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java b/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java index 9c325c1c9..efbdac50d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/FlipFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -37,6 +39,7 @@ public class FlipFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_FLIP); effect.setParameter("horizontal", flips[0]); diff --git a/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java b/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java index 04867c6ac..596d1b608 100644 --- a/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/GrainFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class GrainFilter extends AbstractScaleFilter { public static final Creator<GrainFilter> CREATOR = creatorOf(GrainFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_GRAIN); effect.setParameter("strength", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java b/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java index b0e94ef7c..bf4f4c713 100644 --- a/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/GrayscaleFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class GrayscaleFilter extends Filter { public static final Creator<GrayscaleFilter> CREATOR = creatorOf(GrayscaleFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_GRAYSCALE).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java b/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java index e079c2e58..3d451f1dd 100644 --- a/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/HighlightFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class HighlightFilter extends AbstractScaleFilter { public static final Creator<HighlightFilter> CREATOR = creatorOf(HighlightFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_BLACKWHITE); effect.setParameter("black", 0f); diff --git a/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java b/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java index 16a1d61e9..594fd11eb 100644 --- a/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/LomoishFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class LomoishFilter extends Filter { public static final Creator<LomoishFilter> CREATOR = creatorOf(LomoishFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_LOMOISH).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java b/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java index db702d7e3..327941b2f 100644 --- a/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/NegativeFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class NegativeFilter extends Filter { public static final Creator<NegativeFilter> CREATOR = creatorOf(NegativeFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_NEGATIVE).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java b/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java index 23e78bffb..805a87b45 100644 --- a/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/PosterizeFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class PosterizeFilter extends Filter { public static final Creator<PosterizeFilter> CREATOR = creatorOf(PosterizeFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_POSTERIZE).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java b/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java index 32e8f7c30..1bfcde5a7 100644 --- a/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/RedEyeFilter.java @@ -16,11 +16,13 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.graphics.PointF; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; import java.util.Vector; @@ -42,6 +44,7 @@ public class RedEyeFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_REDEYE); float[] centers = new float[redeyes.size() * 2]; diff --git a/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java b/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java index d820bdac6..a885e2538 100644 --- a/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/RotateFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -39,6 +41,7 @@ public class RotateFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { if (degrees % 180 != 0) { dst.changeDimension(src.height(), src.width()); diff --git a/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java b/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java index af08a7b9c..dab06e05d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/SaturationFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class SaturationFilter extends AbstractScaleFilter { public static final Creator<SaturationFilter> CREATOR = creatorOf(SaturationFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_SATURATE); effect.setParameter("scale", (scale - 0.5f) * 2); diff --git a/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java b/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java index d95c0d84c..efd130b37 100644 --- a/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/SepiaFilter.java @@ -16,8 +16,10 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -28,6 +30,7 @@ public class SepiaFilter extends Filter { public static final Creator<SepiaFilter> CREATOR = creatorOf(SepiaFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { getEffect(EffectFactory.EFFECT_SEPIA).apply( src.texture(), src.width(), src.height(), dst.texture()); diff --git a/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java b/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java index 03960e405..fd214b3a3 100644 --- a/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/ShadowFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class ShadowFilter extends AbstractScaleFilter { public static final Creator<ShadowFilter> CREATOR = creatorOf(ShadowFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_BLACKWHITE); effect.setParameter("black", scale * 0.5f); diff --git a/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java b/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java index f066dcf75..90c0ec79b 100644 --- a/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/SharpenFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class SharpenFilter extends AbstractScaleFilter { public static final Creator<SharpenFilter> CREATOR = creatorOf(SharpenFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_SHARPEN); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java b/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java index bf4ace589..f6e3bf08c 100644 --- a/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/StraightenFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -37,6 +39,7 @@ public class StraightenFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_STRAIGHTEN); effect.setParameter("maxAngle", MAX_DEGREES); diff --git a/src/com/android/gallery3d/photoeditor/filters/TintFilter.java b/src/com/android/gallery3d/photoeditor/filters/TintFilter.java index 7a7463e4c..eb3a831eb 100644 --- a/src/com/android/gallery3d/photoeditor/filters/TintFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/TintFilter.java @@ -16,10 +16,12 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; import android.os.Parcel; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -36,6 +38,7 @@ public class TintFilter extends Filter { } @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_TINT); effect.setParameter("tint", color); diff --git a/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java b/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java index 59034615f..4f6b6526d 100644 --- a/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java +++ b/src/com/android/gallery3d/photoeditor/filters/VignetteFilter.java @@ -16,9 +16,11 @@ package com.android.gallery3d.photoeditor.filters; +import android.annotation.TargetApi; import android.media.effect.Effect; import android.media.effect.EffectFactory; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.photoeditor.Photo; /** @@ -29,6 +31,7 @@ public class VignetteFilter extends AbstractScaleFilter { public static final Creator<VignetteFilter> CREATOR = creatorOf(VignetteFilter.class); @Override + @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) public void process(Photo src, Photo dst) { Effect effect = getEffect(EffectFactory.EFFECT_VIGNETTE); effect.setParameter("scale", scale); diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java index fd16b3537..ee5fe3dcb 100644 --- a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java +++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java @@ -22,6 +22,7 @@ import android.graphics.SurfaceTexture; import com.android.gallery3d.common.ApiHelper; +@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) public abstract class SurfaceTextureScreenNail implements ScreenNail, SurfaceTexture.OnFrameAvailableListener { @SuppressWarnings("unused") diff --git a/tests/src/com/android/gallery3d/exif/ExifParserTest.java b/tests/src/com/android/gallery3d/exif/ExifParserTest.java index 34bbbda5f..8ae25e59a 100644 --- a/tests/src/com/android/gallery3d/exif/ExifParserTest.java +++ b/tests/src/com/android/gallery3d/exif/ExifParserTest.java @@ -131,6 +131,8 @@ public class ExifParserTest extends InstrumentationTestCase { ExifInvalidFormatException { int type = ifdParser.next(); int tagNumber=0; + boolean isEnterNextIfd = false; + boolean isEnterExifIfd = false; while (type != IfdParser.TYPE_END) { switch (type) { case IfdParser.TYPE_NEW_TAG: @@ -146,11 +148,13 @@ public class ExifParserTest extends InstrumentationTestCase { break; case IfdParser.TYPE_NEXT_IFD: parseIfd1(ifdParser.parseIfdBlock()); + isEnterNextIfd = true; break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: tag = ifdParser.getCorrespodingExifTag(); if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { parseExifIfd(ifdParser.parseIfdBlock()); + isEnterExifIfd = true; } else { checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mIfd0Value); tagNumber++; @@ -160,6 +164,8 @@ public class ExifParserTest extends InstrumentationTestCase { type = ifdParser.next(); } assertEquals(mIfd0Value.size(), tagNumber); + assertTrue(isEnterNextIfd); + assertTrue(isEnterExifIfd); } private void parseIfd1(IfdParser ifdParser) throws IOException, @@ -196,15 +202,21 @@ public class ExifParserTest extends InstrumentationTestCase { ExifInvalidFormatException { int type = ifdParser.next(); int tagNumber = 0; + boolean isHasInterIfd = false; + boolean isEnterInterIfd = false; while (type != IfdParser.TYPE_END) { switch (type) { case IfdParser.TYPE_NEW_TAG: ExifTag tag = ifdParser.readTag(); - if (tag.getDataSize() > 4 - || tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) { + if (tag.getDataSize() > 4) { + long offset = ifdParser.readUnsignedInt(); + assertTrue(offset <= Integer.MAX_VALUE); + ifdParser.waitValueOfTag(tag, offset); + } else if (tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) { long offset = ifdParser.readUnsignedInt(); assertTrue(offset <= Integer.MAX_VALUE); ifdParser.waitValueOfTag(tag, offset); + isHasInterIfd = true; } else { checkTag(tag, ifdParser, mExifIfdValue); tagNumber++; @@ -217,6 +229,7 @@ public class ExifParserTest extends InstrumentationTestCase { tag = ifdParser.getCorrespodingExifTag(); if (tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) { parseInteroperabilityIfd(ifdParser.parseIfdBlock()); + isEnterInterIfd = true; } else { checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mExifIfdValue); tagNumber++; @@ -226,6 +239,9 @@ public class ExifParserTest extends InstrumentationTestCase { type = ifdParser.next(); } assertEquals(mExifIfdValue.size(), tagNumber); + if (isHasInterIfd) { + assertTrue(isEnterInterIfd); + } } private void parseInteroperabilityIfd(IfdParser ifdParser) throws IOException, ExifInvalidFormatException { @@ -283,12 +299,8 @@ public class ExifParserTest extends InstrumentationTestCase { } break; case ExifTag.TYPE_ASCII: - buf = new byte[tag.getComponentCount()]; - parser.read(buf); - int length = 0; - while (buf[length] != 0 && length < buf.length) length++; - // trim the string to fit the answer from xml - sbuilder.append(new String(buf, 0, length).trim()); + // trim the string for comparison between xml + sbuilder.append(parser.readString(tag.getComponentCount()).trim()); break; case ExifTag.TYPE_INT: for(int i = 0; i < tag.getComponentCount(); i++) { @@ -338,6 +350,7 @@ public class ExifParserTest extends InstrumentationTestCase { ExifParser exifParser = new ExifParser(); IfdParser ifdParser = exifParser.parse(mImageInputStream); int type = ifdParser.next(); + boolean isEnterNextIfd = false; while (type != IfdParser.TYPE_END) { switch (type) { case IfdParser.TYPE_NEW_TAG: @@ -345,6 +358,7 @@ public class ExifParserTest extends InstrumentationTestCase { break; case IfdParser.TYPE_NEXT_IFD: parseIfd1(ifdParser.parseIfdBlock()); + isEnterNextIfd = true; break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: // We won't get this since to skip everything @@ -353,11 +367,14 @@ public class ExifParserTest extends InstrumentationTestCase { } type = ifdParser.next(); } + assertTrue(isEnterNextIfd); } public void testOnlySaveSomeValue() throws ExifInvalidFormatException, IOException { ExifParser exifParser = new ExifParser(); IfdParser ifdParser = exifParser.parse(mImageInputStream); + boolean isEnterNextIfd = false; + boolean isEnterExifIfd = false; int type = ifdParser.next(); while (type != IfdParser.TYPE_END) { switch (type) { @@ -375,11 +392,13 @@ public class ExifParserTest extends InstrumentationTestCase { break; case IfdParser.TYPE_NEXT_IFD: parseIfd1(ifdParser.parseIfdBlock()); + isEnterNextIfd = true; break; case IfdParser.TYPE_VALUE_OF_PREV_TAG: tag = ifdParser.getCorrespodingExifTag(); if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) { parseExifIfd(ifdParser.parseIfdBlock()); + isEnterExifIfd = true; } else { checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mIfd0Value); } @@ -387,6 +406,8 @@ public class ExifParserTest extends InstrumentationTestCase { } type = ifdParser.next(); } + assertTrue(isEnterNextIfd); + assertTrue(isEnterExifIfd); } public void testReadThumbnail() throws ExifInvalidFormatException, IOException { @@ -417,6 +438,12 @@ public class ExifParserTest extends InstrumentationTestCase { long unsignedInt = ifdParser.readUnsignedInt(); assertTrue(unsignedInt <= Integer.MAX_VALUE); thumbSize = (int) unsignedInt; + } else if (tag.getTagId() == ExifTag.TIFF_TAG.TAG_COMPRESSION) { + if (ifdParser.readUnsignedShort() == + ExifTag.TIFF_TAG.COMPRESSION_UNCOMPRESSION) { + // This test doesn't apply to uncompression thumbnail. + return; + } } isFinishRead = thumbOffset != 0 && thumbSize != 0; break; |