Fat*_*tie 3 cgimageref uigraphicscontext drawinrect
以下是如何在上下文中绘制UIImage:
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f);
[someUIImage drawInRect:CGRectMake(...)];
[someOtherUIImage drawInRect:CGRectMake(...)];
[someOtherUIImage drawInRect:CGRectMake(...)];
UIImage *yourResult = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
没问题.但是,假设我有一个以某种方式构建的CGImageRef.
CGImageRef happyImageRef = CGImageCreateWithImageInRect(blah blah);
Run Code Online (Sandbox Code Playgroud)
我想把它绘制到上下文中.
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f);
[ happyImageRef .. somehowDrawInRect:CGRectMake(...)];
UIImage *yourResult = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
你是怎样做的?
要清楚,显然你可以将它转换为UIImage
UIImage *wasteful = [UIImage imageWithCGImage:happyImageRef];
Run Code Online (Sandbox Code Playgroud)
但这看起来非常低效.怎么做?
我确定我很困惑或遗漏了一些简单的东西,谢谢.
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f);
CGContextDrawImage(UIGraphicsGetCurrentContext(),CGRectMake(...), happyImageRef);
UIImage *yourResult = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2186 次 |
| 最近记录: |