【发布时间】:2011-12-26 16:57:10
【问题描述】:
好的,使用 coregraphics,我正在构建一个稍后将在 CGContextClipToMask 操作中使用的图像。它看起来像下面这样:
UIImage *eyes = [UIImage imageNamed:@"eyes"];
UIImage *mouth = [UIImage imageNamed:@"mouth"];
UIGraphicsBeginImageContext(CGSizeMake(150, 150));
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0, 0, 0, 1);
CGContextFillRect(context, bounds);
[eyes drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1];
[mouth drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1];
// how can i now get a CGImageRef here to use in a masking operation?
UIGraphicsEndImageContext();
现在,正如您在评论中看到的那样,我想知道我将如何实际使用我建立的图像。我在这里使用核心图形而不只是构建 UIImage 的原因是我正在创建的透明度非常重要。如果我只是从上下文中获取一个 UIImage,当它用作蒙版时,它只会应用于所有内容......更重要的是,使用这种方法使用部分透明的蒙版会有什么问题吗?
【问题讨论】:
-
Drawing into CGImageRef 的可能重复项
标签: ios cocoa-touch uikit core-graphics mask