diff options
| author | Byunghun Jeon <bjeon@codeaurora.org> | 2015-11-24 15:19:29 -0800 |
|---|---|---|
| committer | Jay Wang <jaywang@codeaurora.org> | 2015-12-22 17:35:56 -0800 |
| commit | 62fac4f9fefc7d11091e3f1e125fa2587c38330a (patch) | |
| tree | 818aaab95b97aac8520cb7b0e6d35fcc2a0e1e92 /src | |
| parent | d67e88d910bb451d041e32c02feecee24e562f51 (diff) | |
| download | android_packages_apps_Gallery2-62fac4f9fefc7d11091e3f1e125fa2587c38330a.tar.gz android_packages_apps_Gallery2-62fac4f9fefc7d11091e3f1e125fa2587c38330a.tar.bz2 android_packages_apps_Gallery2-62fac4f9fefc7d11091e3f1e125fa2587c38330a.zip | |
Gallery2: Crop DDM output for smaller FOV oon aux Camera
When the FOV on the aux camera is smaller than the main,
DDM is forced to crop the affected area due to a smaller co-visible
intersection between the two shots. Gallery will take this into
consideration and crop the resulting bitmap with the ROI rect
provided by DDM.
Change-Id: If0f1ea9815650e4b7cf6cdb6d1f5a9f2638b92ee
Diffstat (limited to 'src')
3 files changed, 60 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java index ed3552bd5..b9bd574f4 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java @@ -162,6 +162,26 @@ public class ImageFilterDualCamFusion extends ImageFilter { holder = new GeometryHolder(); } + RectF roiRectF = new RectF(); + roiRectF.left = (float)roiRect[0]/(float)filteredW; + roiRectF.top = (float)roiRect[1]/(float)filteredH; + roiRectF.right = (float)(roiRect[0] + roiRect[2])/(float)filteredW; + roiRectF.bottom = (float)(roiRect[1] + roiRect[3])/(float)filteredH; + + // Check for ROI cropping + if(!FilterCropRepresentation.getNil().equals(roiRectF)) { + if(FilterCropRepresentation.getNil().equals(holder.crop)) { + // no crop filter, set crop to be roiRect + holder.crop.set(roiRectF); + } else if(roiRectF.contains(holder.crop) == false) { + // take smaller intersecting area between roiRect and crop rect + holder.crop.left = Math.max(holder.crop.left, roiRectF.left); + holder.crop.top = Math.max(holder.crop.top, roiRectF.top); + holder.crop.right = Math.min(holder.crop.right, roiRectF.right); + holder.crop.bottom = Math.min(holder.crop.bottom, roiRectF.bottom); + } + } + RectF crop = new RectF(); Matrix m = GeometryMathUtils.getOriginalToScreen(holder, crop, true, filteredW, filteredH, bmWidth, bmHeight); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java index 1d8417992..a9ee61ca5 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java @@ -133,7 +133,6 @@ public class ImageFilterDualCamSketch extends ImageFilter { }); return bitmap; } else { - mPaint.reset(); mPaint.setAntiAlias(true); if(quality == FilterEnvironment.QUALITY_FINAL) { @@ -152,6 +151,26 @@ public class ImageFilterDualCamSketch extends ImageFilter { holder = new GeometryHolder(); } + RectF roiRectF = new RectF(); + roiRectF.left = (float)roiRect[0]/(float)filteredW; + roiRectF.top = (float)roiRect[1]/(float)filteredH; + roiRectF.right = (float)(roiRect[0] + roiRect[2])/(float)filteredW; + roiRectF.bottom = (float)(roiRect[1] + roiRect[3])/(float)filteredH; + + // Check for ROI cropping + if(!FilterCropRepresentation.getNil().equals(roiRectF)) { + if(FilterCropRepresentation.getNil().equals(holder.crop)) { + // no crop filter, set crop to be roiRect + holder.crop.set(roiRectF); + } else if(roiRectF.contains(holder.crop) == false) { + // take smaller intersecting area between roiRect and crop rect + holder.crop.left = Math.max(holder.crop.left, roiRectF.left); + holder.crop.top = Math.max(holder.crop.top, roiRectF.top); + holder.crop.right = Math.min(holder.crop.right, roiRectF.right); + holder.crop.bottom = Math.min(holder.crop.bottom, roiRectF.bottom); + } + } + RectF crop = new RectF(); Matrix m = GeometryMathUtils.getOriginalToScreen(holder, crop, true, filteredW, filteredH, bmWidth, bmHeight); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java index 59918cf2e..318833dfa 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java @@ -166,6 +166,26 @@ public class ImageFilterDualCamera extends ImageFilter { holder = new GeometryHolder(); } + RectF roiRectF = new RectF(); + roiRectF.left = (float)roiRect[0]/(float)filteredW; + roiRectF.top = (float)roiRect[1]/(float)filteredH; + roiRectF.right = (float)(roiRect[0] + roiRect[2])/(float)filteredW; + roiRectF.bottom = (float)(roiRect[1] + roiRect[3])/(float)filteredH; + + // Check for ROI cropping + if(!FilterCropRepresentation.getNil().equals(roiRectF)) { + if(FilterCropRepresentation.getNil().equals(holder.crop)) { + // no crop filter, set crop to be roiRect + holder.crop.set(roiRectF); + } else if(roiRectF.contains(holder.crop) == false) { + // take smaller intersecting area between roiRect and crop rect + holder.crop.left = Math.max(holder.crop.left, roiRectF.left); + holder.crop.top = Math.max(holder.crop.top, roiRectF.top); + holder.crop.right = Math.min(holder.crop.right, roiRectF.right); + holder.crop.bottom = Math.min(holder.crop.bottom, roiRectF.bottom); + } + } + RectF crop = new RectF(); Matrix m = GeometryMathUtils.getOriginalToScreen(holder, crop, true, filteredW, filteredH, bmWidth, bmHeight); |
