2011-12-26 4 views
8

コアグラフィックを使用して、私は後でCGContextClipToMask操作で使用される画像を構築しています。これは、次のようになります。Context-Drawn画像からCGImageRefを取得するには?

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をつかまえれば、それがマスクとして使用されると、すべてに適用されます...さらに、このメソッドを使用して部分的に透明なマスクを使用することに問題はありますか?

+0

[Drawing into CGImageRef](http://stackoverflow.com/questions/4257043/drawing-into-cgimageref) –

答えて

12
CGImageRef result = CGBitmapContextCreateImage(UIGraphicsGetCurrentContext()); 
関連する問題