Search in sources :

Example 1 with MasterImage

use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method cancelCurrentFilter.

public void cancelCurrentFilter() {
    MasterImage masterImage = MasterImage.getImage();
    HistoryManager adapter = masterImage.getHistory();
    int position = adapter.undo();
    masterImage.onHistoryItemClick(position);
    invalidateViews();
    if (!masterImage.hasFusionApplied()) {
        masterImage.setFusionUnderlay(null);
        masterImage.setScaleFactor(1);
        masterImage.resetTranslation();
    }
    clearWaterMark();
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) HistoryManager(com.android.gallery3d.filtershow.history.HistoryManager) Point(android.graphics.Point)

Example 2 with MasterImage

use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.

the class EditorCrop method reflectCurrentFilter.

@Override
public void reflectCurrentFilter() {
    MasterImage master = MasterImage.getImage();
    master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(FilterCropRepresentation.SERIALIZATION_NAME));
    super.reflectCurrentFilter();
    FilterRepresentation rep = getLocalRepresentation();
    if (rep == null || rep instanceof FilterCropRepresentation) {
        mImageCrop.setFilterCropRepresentation((FilterCropRepresentation) rep);
    } else {
        Log.w(TAG, "Could not reflect current filter, not of type: " + FilterCropRepresentation.class.getSimpleName());
    }
    mImageCrop.invalidate();
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterCropRepresentation(com.android.gallery3d.filtershow.filters.FilterCropRepresentation)

Example 3 with MasterImage

use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.

the class EditorMirror method reflectCurrentFilter.

@Override
public void reflectCurrentFilter() {
    MasterImage master = MasterImage.getImage();
    master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(FilterMirrorRepresentation.SERIALIZATION_NAME));
    super.reflectCurrentFilter();
    FilterRepresentation rep = getLocalRepresentation();
    if (rep == null || rep instanceof FilterMirrorRepresentation) {
        mImageMirror.setFilterMirrorRepresentation((FilterMirrorRepresentation) rep);
    } else {
        Log.w(TAG, "Could not reflect current filter, not of type: " + FilterMirrorRepresentation.class.getSimpleName());
    }
    mImageMirror.invalidate();
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) FilterMirrorRepresentation(com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 4 with MasterImage

use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.

the class ImageFilterDualCamera method apply.

@Override
public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
    if (mParameters == null) {
        return bitmap;
    }
    Point point = new Point(mParameters.getPoint());
    if (!point.equals(-1, -1)) {
        MasterImage image = MasterImage.getImage();
        Size size = getFilteredSize(image, quality);
        DualCameraEffect effect = image.getDualCameraEffect(size.getWidth(), size.getHeight());
        if (effect == null) {
            return bitmap;
        }
        size = effect.size();
        Bitmap filteredBitmap = image.getBitmapCache().getBitmap(size.getWidth(), size.getHeight(), BitmapCache.FILTERS);
        Log.d(TAG, "filtered: " + size.getWidth() + "x" + size.getHeight());
        filteredBitmap.setHasAlpha(mSupportFusion);
        float intensity = getIntensity();
        effect.map(point);
        int effectType = getEffectType();
        boolean result = effect.render(effectType, point.x, point.y, filteredBitmap, intensity);
        if (!result) {
            showToast(R.string.dualcam_no_segment_toast, Toast.LENGTH_SHORT);
            return bitmap;
        }
        mPaint.reset();
        mPaint.setAntiAlias(true);
        if (quality == FilterEnvironment.QUALITY_FINAL) {
            mPaint.setFilterBitmap(true);
            mPaint.setDither(true);
        }
        Canvas canvas = new Canvas(bitmap);
        ImagePreset preset = getEnvironment().getImagePreset();
        int bmWidth = bitmap.getWidth();
        int bmHeight = bitmap.getHeight();
        GeometryHolder holder;
        if (preset.getDoApplyGeometry()) {
            holder = GeometryMathUtils.unpackGeometry(preset.getGeometryFilters());
        } else {
            holder = new GeometryHolder();
        }
        RectF roiRectF = new RectF();
        roiRectF.left = 0;
        roiRectF.top = 0;
        roiRectF.right = 1;
        roiRectF.bottom = 1;
        int zoomOrientation = image.getZoomOrientation();
        if (isRotated(zoomOrientation)) {
            Matrix mt = new Matrix();
            mt.preRotate(GeometryMathUtils.getRotationForOrientation(zoomOrientation), 0.5f, 0.5f);
            mt.mapRect(roiRectF);
        }
        // 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)) {
                // 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, size.getWidth(), size.getHeight(), bmWidth, bmHeight);
        if (mSupportFusion)
            canvas.drawColor(0, PorterDuff.Mode.CLEAR);
        canvas.save();
        canvas.clipRect(crop);
        canvas.drawBitmap(filteredBitmap, m, mPaint);
        canvas.restore();
        image.getBitmapCache().cache(filteredBitmap);
    }
    return bitmap;
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) GeometryHolder(com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder) Size(android.util.Size) Canvas(android.graphics.Canvas) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) DualCameraEffect(com.android.gallery3d.filtershow.tools.DualCameraEffect)

Example 5 with MasterImage

use of com.android.gallery3d.filtershow.imageshow.MasterImage in project android_packages_apps_Gallery2 by LineageOS.

the class EditorStraighten method reflectCurrentFilter.

@Override
public void reflectCurrentFilter() {
    MasterImage master = MasterImage.getImage();
    master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(FilterStraightenRepresentation.SERIALIZATION_NAME));
    super.reflectCurrentFilter();
    FilterRepresentation rep = getLocalRepresentation();
    if (rep == null || rep instanceof FilterStraightenRepresentation) {
        mImageStraighten.setFilterStraightenRepresentation((FilterStraightenRepresentation) rep);
    } else {
        Log.w(TAG, "Could not reflect current filter, not of type: " + FilterStraightenRepresentation.class.getSimpleName());
    }
    mImageStraighten.invalidate();
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) FilterStraightenRepresentation(com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Aggregations

MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)9 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)5 Bitmap (android.graphics.Bitmap)2 Canvas (android.graphics.Canvas)2 Matrix (android.graphics.Matrix)2 Paint (android.graphics.Paint)2 Point (android.graphics.Point)2 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)2 HistoryManager (com.android.gallery3d.filtershow.history.HistoryManager)2 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)2 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 Size (android.util.Size)1 FilterCropRepresentation (com.android.gallery3d.filtershow.filters.FilterCropRepresentation)1 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)1 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)1 FilterStraightenRepresentation (com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation)1 GeometryHolder (com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder)1 DualCameraEffect (com.android.gallery3d.filtershow.tools.DualCameraEffect)1