android - 从位图创建蒙版
解决方案
该网站上提出的问题似乎与您的问题相似,答案应该可以帮助您。他们的代码早在 2003 年是用 Java 编写的,但我相信您是在询问您计划在 Android Studio 中从您的标签中编程的东西,我猜是 Java。您的问题有点模糊,但也许这个网站将是一个很好的起点。有更长的解决方案,写出了完整的代码,但我会发布列出的解决方案之一。
该论坛上发布的解决方案之一是:
//get the image pixel
int imgPixel = image.getRGB(x,y);
//get the mask pixel
int maskPixel = mask.getRGB(x,y);
//now, get rid of everything but the blue channel
//and shift the blue channel into the alpha channels sample space.
maskPixel = (maskPixel &0xFF)<<24
//now, merge img and mask pixels and copy them back to the image
image.setRGB(x,y,imgPixel|maskPixel);
推荐阅读
- tensorflow - 迁移学习如何与 TensorFlow 对象检测 API 配合使用?
- amazon-web-services - 如何使用 fluent bit 将 EKS (fargate) 容器日志发送到云手表?
- svg - 如何在 HTML 中生成 SVG 波形
- php - 显示是否比当前时间早 30 分钟
- ruby - ruby-runtime:无法在 Jenkins 中初始化 | MAC OS 大苏尔
- mobile - 我在带有模态引导的移动设备中遇到问题视口?
- mysql - 将 MySQL 脚本转换为涉及 DATE_FORMAT 的 Presto
- google-classroom - 如何为 Web 应用程序集成和测试 Google Classroom
- css - CSS如何将不同尺寸的图像与行内的文本对齐?
- python - Tensorflow对象检测,在教程中重新排列代码时列表索引超出范围错误