ios – 如何从上下文绘制的图像中获取CGImageRef?

ios – 如何从上下文绘制的图像中获取CGImageRef?,第1张

概述好吧使用coregraphics,我正在构建一个稍后将用于CGContextClipToMask *** 作的图像.它看起来像下面这样: UIImage *eyes = [UIImage imageNamed:@"eyes"]; UIImage *mouth = [UIImage imageNamed:@"mouth"]; UIGraphicsBeginImageContext(CGSi 好吧使用coregraphics,我正在构建一个稍后将用于CGContextClipToMask *** 作的图像.它看起来像下面这样:
UIImage *eyes = [UIImage imagenamed:@"eyes"];    UIImage *mouth = [UIImage imagenamed:@"mouth"];    UIGraphicsBeginImageContext(CGSizeMake(150,150));    CGContextRef context = UIGraphicsGetCurrentContext();    CGContextSetRGBFillcolor(context,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,当它被用作掩码时,它将仅适用于所有内容……更重要的是,使用此方法使用部分透明的掩码会有任何问题吗?

解决方法
CGImageRef result = CGBitmapContextCreateImage(UIGraphicsGetCurrentContext());
总结

以上是内存溢出为你收集整理的ios – 如何从上下文绘制的图像中获取CGImageRef?全部内容,希望文章能够帮你解决ios – 如何从上下文绘制的图像中获取CGImageRef?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1105623.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存