Search in sources :

Example 26 with ImagePreset

use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.

the class MasterImage method onHistoryItemClick.

public void onHistoryItemClick(int position, boolean updateCategory) {
    HistoryItem historyItem = mHistory.getItem(position);
    // We need a copy from the history
    if (historyItem == null) {
        return;
    }
    ImagePreset newPreset = new ImagePreset(historyItem.getImagePreset());
    // don't need to add it to the history
    setPreset(newPreset, historyItem.getFilterRepresentation(), false, updateCategory);
    mHistory.setCurrentPreset(position);
}
Also used : HistoryItem(com.android.gallery3d.filtershow.history.HistoryItem) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset)

Example 27 with ImagePreset

use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.

the class SaveWaterMark method saveImage.

public void saveImage(Context context, final Bitmap bitmap, Uri selectedUri, Handler handler, int quality, float scaleFactor, boolean isScale) {
    mContext = context;
    WaterMarkView mWaterMarkView = waterMarkRp.getWaterMarkView();
    mWaterMarkView.clearEditTextCursor();
    Bitmap markBitmap = mWaterMarkView.creatNewPhoto();
    new AsyncTask<Bitmap, Void, Uri>() {

        @Override
        protected Uri doInBackground(Bitmap... bitmaps) {
            ImagePreset ip = MasterImage.getImage().getPreset();
            FilterFusionRepresentation fusionRep = findFusionRepresentation(ip);
            boolean hasFusion = (fusionRep != null && fusionRep.hasUnderlay());
            Bitmap destinationBitmap = createBitmap(bitmap, bitmaps[0]);
            Bitmap fusionBmp = null;
            // sampleSize is 1 for fusion bitmap of 1:1 size,
            // sizeConstraint is 0 for fusion without width or height constraint.
            final int sampleSize = 1, sizeConstraint = 0;
            if (hasFusion) {
                fusionBmp = SaveImage.flattenFusion(mContext, Uri.parse(fusionRep.getUnderlay()), destinationBitmap, sizeConstraint, sampleSize);
                if (fusionBmp != null) {
                    destinationBitmap.recycle();
                    destinationBitmap = fusionBmp;
                }
            }
            File destinationFile = SaveImage.getNewFile(context, selectedUri);
            // ExifInterface exif = getExifData(context, selectedUri);
            long time = System.currentTimeMillis();
            Uri saveUri = selectedUri;
            if (scaleFactor != 1f) {
                // if we have a valid size
                int w = (int) (destinationBitmap.getWidth() * scaleFactor);
                int h = (int) (destinationBitmap.getHeight() * scaleFactor);
                if (w == 0 || h == 0) {
                    w = 1;
                    h = 1;
                }
                destinationBitmap = Bitmap.createScaledBitmap(destinationBitmap, w, h, true);
            }
            if (SaveImage.putExifData(destinationFile, mExif, destinationBitmap, quality)) {
                saveUri = SaveImage.linkNewFileToUri(context, selectedUri, destinationFile, time, false);
            }
            destinationBitmap.recycle();
            if (saveUri != selectedUri) {
                Log.d(GalleryActivity.QSST, "watermark saved successfully" + waterMarkRp.getSerializationName());
            }
            return saveUri;
        }

        @Override
        protected void onPostExecute(Uri uri) {
            if (isScale)
                return;
            Message message = new Message();
            message.what = MARK_SAVE_COMPLETE;
            message.obj = uri;
            handler.sendMessage(message);
        }
    }.execute(markBitmap);
}
Also used : Bitmap(android.graphics.Bitmap) Message(android.os.Message) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) Uri(android.net.Uri) File(java.io.File) WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView)

Example 28 with ImagePreset

use of com.android.gallery3d.filtershow.pipeline.ImagePreset in project android_packages_apps_Gallery2 by LineageOS.

the class ImageFilterTinyPlanet method apply.

@Override
public Bitmap apply(Bitmap bitmapIn, float scaleFactor, int quality) {
    int w = bitmapIn.getWidth();
    int h = bitmapIn.getHeight();
    int outputSize = (int) (w / 2f);
    ImagePreset preset = getEnvironment().getImagePreset();
    Bitmap mBitmapOut = null;
    if (preset != null) {
        XMPMeta xmp = ImageLoader.getXmpObject(MasterImage.getImage().getActivity());
        // Do nothing, just use bitmapIn as is if we don't have XMP.
        if (xmp != null) {
            bitmapIn = applyXmp(bitmapIn, xmp, w);
        }
    }
    if (mBitmapOut != null) {
        if (outputSize != mBitmapOut.getHeight()) {
            mBitmapOut = null;
        }
    }
    while (mBitmapOut == null) {
        try {
            mBitmapOut = getEnvironment().getBitmap(outputSize, outputSize, BitmapCache.TINY_PLANET);
        } catch (java.lang.OutOfMemoryError e) {
            System.gc();
            outputSize /= 2;
            Log.v(LOGTAG, "No memory to create Full Tiny Planet create half");
        }
    }
    nativeApplyFilter(bitmapIn, bitmapIn.getWidth(), bitmapIn.getHeight(), mBitmapOut, outputSize, mParameters.getZoom() / 100f, mParameters.getAngle());
    return mBitmapOut;
}
Also used : Bitmap(android.graphics.Bitmap) XMPMeta(com.adobe.xmp.XMPMeta) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset)

Aggregations

ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)28 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)8 Bitmap (android.graphics.Bitmap)7 Matrix (android.graphics.Matrix)4 Point (android.graphics.Point)4 FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)4 RectF (android.graphics.RectF)3 Uri (android.net.Uri)3 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)3 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)3 Canvas (android.graphics.Canvas)2 Paint (android.graphics.Paint)2 Rect (android.graphics.Rect)2 XMPMeta (com.adobe.xmp.XMPMeta)2 Action (com.android.gallery3d.filtershow.category.Action)2 FilterPresetSource (com.android.gallery3d.filtershow.data.FilterPresetSource)2 SaveOption (com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)2 HistoryItem (com.android.gallery3d.filtershow.history.HistoryItem)2 GeometryHolder (com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder)2 MasterImage (com.android.gallery3d.filtershow.imageshow.MasterImage)2