android – 使用Path剪切带有Bitmap的区域

android – 使用Path剪切带有Bitmap的区域,第1张

概述我正试图从图像中剪切拼图块,创建一个新的位图图像.我正在使用Path对象来执行此 *** 作.这是目前的结果. 我是如何实现这一目标的 Path path = new Path(); // Multiple path methods to create shape of puzzle piece... path.close(); Bitmap source = BitmapFac 我正试图从图像中剪切拼图块,创建一个新的位图图像.我正在使用Path对象来执行此 *** 作.这是目前的结果.

我是如何实现这一目标的

Path path = new Path();    // Multiple path methods to create shape of puzzle pIEce...    path.close();    Bitmap source = BitmapFactory.decodeResource(getResources(),R.drawable.flowers);    Bitmap workingcopy = source.copy(Bitmap.Config.ARGB_8888,true);    Canvas canvas = new Canvas(workingcopy);    path.setFillType(Path.FillType.INVERSE_WINDING);    Paint paint = new Paint();    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));    canvas.drawPath(path,paint);    ((ImageVIEw) findVIEwByID(R.ID.myImage)).setimageBitmap(workingcopy);

我希望我可以让它透明而不是黑色,并切除路径范围之外的一切.

解决方法 我尝试使用具有透明度的PNG文件,背景是透明的而不是黑色. @H_502_25@ 总结

以上是内存溢出为你收集整理的android – 使用Path剪切带有Bitmap的区域全部内容,希望文章能够帮你解决android – 使用Path剪切带有Bitmap的区域所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1125979.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存