Kor*_* Ou 6 iphone uiimage cgcontext
CGContextRef context = ??; // get from UIImage *oldImage
CGContextSaveGState(context);
CGRect drawRect = CGRectMake(0, 0, 320, 480);
CGContextConcatCTM(context, transform);
UIImage *newImage = [[UIImage alloc] init];
CGContextDrawImage(context, drawRect, newImage.CGImage);
[newImage drawInRect:CGRectMake(0, 0, 320, 480)];
CGContextRestoreGState(context);Run Code Online (Sandbox Code Playgroud)
简而言之,我想要做的是[UIImage - >进行一些转换 - >转换UIImage].
有任何想法吗?十分感谢!!
我想你需要的是:
UIGraphicsBeginImageContextWithOptions(newImageSize, YES, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
// drawing commands go here
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
请注意,UIGraphicsGetImageFromCurrentImageContext()返回一个自动释放的UIImage实例.
| 归档时间: |
|
| 查看次数: |
9378 次 |
| 最近记录: |