iPhone 遮蔽颜色:删除背景颜色

发布于 2024-09-14 17:57:56 字数 377 浏览 2 评论 0原文

我有一系列的头像;每个都有 RGB:255,0,255 的亮粉色背景。

而不是遍历每个头像,并手动去除粉红色背景;有没有办法让 Objective C 为我删除背景(掩盖它)?

头像示例如下:

替代文本 http://img39.imageshack.us/img39 /2645/bluegem.png

我担心的一件事是屏蔽是动态完成的,并且可能会消耗内存;这是我应该关心的事情吗?

另外,假设我将头像放在精灵表中;我可以敷一次面膜然后使用吗?

感谢您的帮助。

I have a series of avatars; each has a hot pink background of RGB:255,0,255.

Rather than going through every avatar, and manually removing the pink background; is there a way to make Objective C remove the background (masking it) for me?

An example of an avatar follows:

alt text http://img39.imageshack.us/img39/2645/bluegem.png

One thing I am concerned about is that the masking is done on the fly, and may cost memory; is this something I should be concerned about?

Additionally, let's say I put the avatars in a spritesheet; could I apply the mask once and work with that?

Thanks for your help.

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

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

发布评论

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

评论(2

爱情眠于流年 2024-09-21 17:57:56

请参阅函数 CGImageCreateWithMaskingColors。我想这就是你所需要的。参见参考:
用颜色遮罩图像

see function CGImageCreateWithMaskingColors. I think this is what you need. See reference:
Masking an Image With Color

睡美人的小仙女 2024-09-21 17:57:56

如果您以编程方式添加按钮,则可以在每次创建头像按钮时设置全局 NSArray 和 addObject:yourButton ,然后当您想要删除背景时,请执行以下操作:

for (UIButton *custom in globalButtonArray) {
    custom.backgroundColor = [UIColor clearColor];
}

If you added the buttons programatically you could set a global NSArray and addObject:yourButton each time you make an avatar button, then when you want to remove the background do this:

for (UIButton *custom in globalButtonArray) {
    custom.backgroundColor = [UIColor clearColor];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文