有没有一种简单的方法可以在图像上绘图来改变透明度?

发布于 2024-12-16 10:50:01 字数 116 浏览 2 评论 0原文

让我详细说明一下:

我想加载图像(最好仅使用石英)并将其设置为透明。然后,我希望能够在该图像上画一条线,并使图像下该线的内容变得可见。这可能吗?它是否涉及某种掩码?如果是,我可能会考虑什么样的性能问题?

Let me elaborate:

I'd like to load an image (ideally just using quartz) and set it to transparent. I would then like to be able to draw a line on that image and have the contents of that line under the image become visible. Is this possible? Would it involve masks of some sort, and if so, what sort of performance issues might I be looking at?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦断已成空 2024-12-23 10:50:01

您可以查看 CGContextSetBlendMode 或者可能在 CGContextClip

使用混合模式时,您首先要透明地绘制图像,然后设置混合模式,然后绘制线条或其他形状。我对混合模式不太了解,但也许其他人可以建议一种合适的混合模式。否则就试试哪一个可行。您也许可以在某些图像处理程序中进行这种试验和错误,您可以在图层上设置混合模式...

剪切时,您首先创建一个剪切路径,使用CGContextClip进行设置,然后画出你的图像。

我相信使用第一种方法你可以有不同的 alpha 值,但使用第二种方法像素将是可见的或隐藏的。

You could either have a look at CGContextSetBlendMode or maybe at CGContextClip.

When using a blend mode you'd first draw your image transparently, then set the blend mode, then draw lines or other shapes. I don't really know much about the blend modes, but maybe somebody else can suggest a suitable one. Otherwise just try which one would work. You might be able to do this trial and error in some image manipulation program where you can set blend modes on layers...

When clipping, you'd first create a clipping path, set that with CGContextClip, and then draw your image.

I believe with the first approach you could have different alpha values, but with the second approach a pixel would be either visible or hidden.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文