使用掩码进行 SDL 位块传输
我有一个 SDL_image/surface(原始图像),我想将其“blit”到另一个 SDL_image/surface 上,该 SDL_image/surface 是一个用于复制原始图像部分的掩码。
掩模使用 255 定义要保留的部分,使用 0 定义需要从图像中删除的区域。
我目前正在对蒙版和原始图像进行像素遍历,这在输出中引起了很多问题。
是否有预先存在的技术可以使用 SDL 的位块传送功能来执行此操作?
I've an SDL_image/surface (the original) that I'd like to "blit" against another SDL_image/surface that is a mask to copy out portions from the original.
The mask uses 255 to define the portions to keep and 0 to define regions that need to be removed from the image.
I'm current doing pixel traversal of the mask and the original image and it's causing a lot of issues in the output.
Is there a pre-existing technique to do this using SDL's blitting functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来你的“面具”是一个阿尔法通道。创建具有 Alpha 支持的 SDL_image。
Sounds like your "mask" is an alpha channel. Create an SDL_image with alpha support.
添加 SDL2 答案,以防有人正在寻找解决方案。没有额外的库。
SDL2 API 中提供以下函数:
用于设置表面中的透明像素。在下面来自我的爱好黑客的示例片段中,它在加载图像时使用。
参考:
https://wiki.libsdl.org/SDL_SetColorKey
Adding an SDL2 answer in case someone is looking for a solution. No additional libs.
The following function is available in the SDL2 API:
It is used to set the transparent pixel in a surface. In the below example snippet from my hobby hack it is used when the image is loaded.
Reference:
https://wiki.libsdl.org/SDL_SetColorKey