Search in sources :

Example 1 with WaterMarkView

use of com.android.gallery3d.filtershow.category.WaterMarkView in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method showWaterMark.

private void showWaterMark(FilterRepresentation representation) {
    FilterWatermarkRepresentation watermarkRepresentation = (FilterWatermarkRepresentation) representation;
    if (mWaterMarkView != null) {
        rlImageContainer.removeView(mWaterMarkView);
        hasWaterMark = false;
        watermarkRepresentation.reset();
    }
    DisplayMetrics dm = getResources().getDisplayMetrics();
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(dm.widthPixels, dm.heightPixels);
    String textHint;
    switch(watermarkRepresentation.getMarkType()) {
        case 0:
            textHint = locationStr;
            break;
        case 2:
            textHint = temperature;
            break;
        default:
            textHint = watermarkRepresentation.getTextHint();
            break;
    }
    WaterMarkView waterMarkView = watermarkRepresentation.getWaterMarkView(textHint);
    rlImageContainer.addView(waterMarkView, params);
    mWaterMarkView = waterMarkView;
    mSaveWaterMark.useRepresentation(representation);
    imgComparison.bringToFront();
    mSaveWaterMark.getExifData(this, mSelectedImageUri);
    mWaterMarkView.mTouchable = true;
    hasWaterMark = true;
}
Also used : FilterWatermarkRepresentation(com.android.gallery3d.filtershow.filters.FilterWatermarkRepresentation) RelativeLayout(android.widget.RelativeLayout) DisplayMetrics(android.util.DisplayMetrics) WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView)

Example 2 with WaterMarkView

use of com.android.gallery3d.filtershow.category.WaterMarkView in project android_packages_apps_Gallery2 by LineageOS.

the class FilterWatermarkRepresentation method getWaterMarkView.

public WaterMarkView getWaterMarkView(String textHint) {
    if (currentMarkView != null) {
        return currentMarkView;
    }
    currentMarkView = new WaterMarkView(mContext, mContext.getResources().getDrawable(getWaterMarkId(), getCurrentTheme()), textHint);
    if (positionInfo != null) {
        currentMarkView.setTextPosition(positionInfo.marginLeft, positionInfo.marginTop, positionInfo.marginRight, positionInfo.marginBottom, positionInfo.gravity, positionInfo.isDip);
    } else {
        currentMarkView.setTextVisibility(false);
    }
    currentMarkView.setImageAlpha(markAlpha >= 0 ? markAlpha : 128);
    return currentMarkView;
}
Also used : WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView)

Example 3 with WaterMarkView

use of com.android.gallery3d.filtershow.category.WaterMarkView 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)

Aggregations

WaterMarkView (com.android.gallery3d.filtershow.category.WaterMarkView)3 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 Message (android.os.Message)1 DisplayMetrics (android.util.DisplayMetrics)1 RelativeLayout (android.widget.RelativeLayout)1 FilterWatermarkRepresentation (com.android.gallery3d.filtershow.filters.FilterWatermarkRepresentation)1 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)1 File (java.io.File)1