Search in sources :

Example 6 with MasterImage

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

the class StateView method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean ret = super.onTouchEvent(event);
    FilterShowActivity activity = (FilterShowActivity) getContext();
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        activity.startTouchAnimation(this, event.getX(), event.getY());
    }
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mStartTouchY = event.getY();
        mStartTouchX = event.getX();
        if (mType == BEGIN) {
            MasterImage.getImage().setShowsOriginal(true);
        }
    }
    if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
        setTranslationX(0);
        setTranslationY(0);
        MasterImage.getImage().setShowsOriginal(false);
        if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_UP) {
            setSelected(true);
            FilterRepresentation representation = getState().getFilterRepresentation();
            MasterImage image = MasterImage.getImage();
            ImagePreset preset = image != null ? image.getCurrentPreset() : null;
            if (getTranslationY() == 0 && image != null && preset != null && representation != image.getCurrentFilterRepresentation() && preset.getRepresentation(representation) != null) {
                activity.showRepresentation(representation);
                setSelected(false);
            }
        }
    }
    if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        float delta = event.getY() - mStartTouchY;
        if (Math.abs(delta) > mDeleteSlope) {
            activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
        }
    }
    return true;
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity) FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation)

Example 7 with MasterImage

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

the class CachingPipeline method render.

public synchronized void render(RenderingRequest request) {
    // TODO: cleanup/remove GEOMETRY / FILTERS paths
    synchronized (CachingPipeline.class) {
        if (getRenderScriptContext() == null) {
            return;
        }
        if ((request.getType() != RenderingRequest.PARTIAL_RENDERING && request.getType() != RenderingRequest.ICON_RENDERING && request.getBitmap() == null) || request.getImagePreset() == null) {
            return;
        }
        if (DEBUG) {
            Log.v(LOGTAG, "render image of type " + getType(request));
        }
        Bitmap bitmap = request.getBitmap();
        ImagePreset preset = request.getImagePreset();
        setupEnvironment(preset, true);
        mFiltersManager.freeFilterResources(preset);
        if (request.getType() == RenderingRequest.PARTIAL_RENDERING) {
            MasterImage master = MasterImage.getImage();
            bitmap = ImageLoader.getScaleOneImageForPreset(master.getActivity(), mEnvironment.getBimapCache(), master.getUri(), request.getBounds(), request.getDestination());
            if (bitmap == null) {
                Log.w(LOGTAG, "could not get bitmap for: " + getType(request));
                return;
            }
        }
        if (request.getType() == RenderingRequest.FULL_RENDERING || request.getType() == RenderingRequest.GEOMETRY_RENDERING || request.getType() == RenderingRequest.FILTERS_RENDERING) {
            updateOriginalAllocation(preset);
        }
        if (DEBUG && bitmap != null) {
            Log.v(LOGTAG, "after update, req bitmap (" + bitmap.getWidth() + "x" + bitmap.getHeight() + " ? resizeOriginal (" + mResizedOriginalBitmap.getWidth() + "x" + mResizedOriginalBitmap.getHeight());
        }
        if (request.getType() == RenderingRequest.FULL_RENDERING || request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
            mOriginalAllocation.copyTo(bitmap);
        } else if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
            mFiltersOnlyOriginalAllocation.copyTo(bitmap);
        }
        if (request.getType() == RenderingRequest.FULL_RENDERING || request.getType() == RenderingRequest.FILTERS_RENDERING || request.getType() == RenderingRequest.ICON_RENDERING || request.getType() == RenderingRequest.PARTIAL_RENDERING || request.getType() == RenderingRequest.STYLE_ICON_RENDERING) {
            if (request.getType() == RenderingRequest.ICON_RENDERING) {
                mEnvironment.setQuality(FilterEnvironment.QUALITY_ICON);
            } else {
                mEnvironment.setQuality(FilterEnvironment.QUALITY_PREVIEW);
            }
            if (request.getType() == RenderingRequest.ICON_RENDERING) {
                Rect iconBounds = request.getIconBounds();
                Bitmap source = MasterImage.getImage().getThumbnailBitmap();
                if (iconBounds.width() > source.getWidth() * 2) {
                    source = MasterImage.getImage().getLargeThumbnailBitmap();
                }
                if (iconBounds != null) {
                    bitmap = mEnvironment.getBitmap(iconBounds.width(), iconBounds.height(), BitmapCache.ICON);
                    Canvas canvas = new Canvas(bitmap);
                    Matrix m = new Matrix();
                    float minSize = Math.min(source.getWidth(), source.getHeight());
                    float maxSize = Math.max(iconBounds.width(), iconBounds.height());
                    float scale = maxSize / minSize;
                    m.setScale(scale, scale);
                    float dx = (iconBounds.width() - (source.getWidth() * scale)) / 2.0f;
                    float dy = (iconBounds.height() - (source.getHeight() * scale)) / 2.0f;
                    m.postTranslate(dx, dy);
                    canvas.drawBitmap(source, m, new Paint(Paint.FILTER_BITMAP_FLAG));
                } else {
                    bitmap = mEnvironment.getBitmapCopy(source, BitmapCache.ICON);
                }
            }
            Bitmap bmp = preset.apply(bitmap, mEnvironment);
            if (!mEnvironment.needsStop()) {
                request.setBitmap(bmp);
            }
            mFiltersManager.freeFilterResources(preset);
        }
    }
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint)

Example 8 with MasterImage

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

the class EditorPanel method cancelCurrentFilter.

public void cancelCurrentFilter() {
    MasterImage masterImage = MasterImage.getImage();
    HistoryManager adapter = masterImage.getHistory();
    int position = adapter.undo();
    masterImage.onHistoryItemClick(position);
    ((FilterShowActivity) getActivity()).invalidateViews();
}
Also used : MasterImage(com.android.gallery3d.filtershow.imageshow.MasterImage) HistoryManager(com.android.gallery3d.filtershow.history.HistoryManager) FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity)

Example 9 with MasterImage

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

the class EditorRotate method reflectCurrentFilter.

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

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