我正在尝试使用CGContextRef
以下代码在图像上绘制:
UIGraphicsBeginImageContextWithOptions(size, false, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
// After getting the context i pass it to a C++ backend by an appropriate wrapper and do some drawing operations.
然后我尝试使用以下代码从上下文中获取图像:
CGImageRef image = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
但这会返回一个大小为 (0,0) 的图像。
我试图通过以下方式获取图像:
CGImageRef image = CGBitmapContextCreateImage(context);
这将返回一个空白图像,其宽度和高度都是原始大小乘以 3。
有什么建议么?