Iphone应用程序:如何填充一个空白区域与核心图像? [英] Iphone App: How to fill an image with empty areas with coregraphics?

查看:237
本文介绍了Iphone应用程序:如何填充一个空白区域与核心图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个为Iphone开发应用程序的初学者,想知道是否可以执行以下操作:

I'm a beginner developing apps for Iphone and was wondering if is possible to do the following:

我有一个图像.png是一个简单的绘图一个以黑色边缘和空白区域为界的图形。我不知道是否有一个方法或模式来填充图像的封闭空白区域。

I have an image .png wich is a simple draw of a figure bounded with black edges and empty areas. I wonder if there is a method or a mode to fill the closed empty areas of the image.

它就像一堆MSpaint填充。

Its like as the pot of MSpaint filling.

我有这个代码:

CGContextRef ctx = UIGraphicsGetCurrentContext();
UIImage *image = [UIImage imageNamed:@"myImage.png"];
CGContextDrawImage(context, CGRectMake(0, 0, 145, 15), image.CGImage);
[image drawInRect:CGRectMake(0, 0, 145, 15)];

现在我不知道该怎么办...

Now i don't know what to do to fill...

如果有人能回答这个问题,我会非常感谢。非常感谢!

I'll be very grateful if someone can answer this question. Thank you very much!

推荐答案


我有一个图片...

I have an image … wich is … bounded with black edges and empty areas.

如果空表示这些区域有字母0,只需填充上下文所需的颜色整个范围的上下文)先,然后在顶部绘制图像。

If by "empty" you mean these areas have alpha zero, simply fill the context with the desired color (filling the entire extent of the context) first, then draw the image on top. The color will show through where the image is transparent, and not where it isn't.

与您要求的更接近的匹配将是使用图像绘制图像。复制混合模式,然后使用Source Out混合模式进行颜色填充。

A closer match to what you asked for would be to draw the image using the Copy blend mode, then do the color fill using the Source Out blend mode.

混合模式是你的朋友;学习他们,因为你可以做很多与他们。

Blend modes are your friend; learn them well, because you can do a lot with them.

这篇关于Iphone应用程序:如何填充一个空白区域与核心图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆