使android中徒手裁剪的图像的部分变暗

编程入门 行业动态 更新时间:2024-10-27 23:24:14
本文介绍了使android中徒手裁剪的图像的部分变暗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想添加免提功能.

现在,借助以下代码,我可以打开图片并在要裁剪的图像部分周围绘制路径:

Till now I can open the picture and draw a path around the part of the image that I want to crop thanks to this code:

stackoverflow/a/18459072/2361533

但是在另一个活动中打开裁剪后的图像之前,我想使裁剪路径的外部变暗,以向用户展示裁剪后的图像.万一他不喜欢这个结果,他可以重置图像.

But before opening the cropped image in another activity, I want to darken the outside part of the crop path, to show the user how the cropped image will be. In case he does not like the result, he could reset the image.

就像下面的图片一样: Android:免费裁剪图片

It would be something like the image here: Android: Free Croping of Image

我该怎么做?

推荐答案

使用以下两种方法作为开始:

Use the following two methods as a start:

setXfermode(new PorterDuffXfermode(Mode.DARKEN)); canvas.clipPath(path, Region.Op.DIFFERENCE);

第一个应用于Paint对象,并使某个区域变暗. 第二个剪切"画布中的路径并取反(使用Region.Op.DIFFERENCE).

The first one is applied to a Paint object and darkens a certain region. The second "clips" the path in your canvas and takes the inverse (using Region.Op.DIFFERENCE).

更多推荐

使android中徒手裁剪的图像的部分变暗

本文发布于:2023-08-02 03:43:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1274331.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   变暗   android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!