iPhone 遮蔽颜色:删除背景颜色
我有一系列的头像;每个都有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅函数 CGImageCreateWithMaskingColors。我想这就是你所需要的。参见参考:
用颜色遮罩图像
see function CGImageCreateWithMaskingColors. I think this is what you need. See reference:
Masking an Image With Color
如果您以编程方式添加按钮,则可以在每次创建头像按钮时设置全局 NSArray 和 addObject:yourButton ,然后当您想要删除背景时,请执行以下操作:
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: