【发布时间】:2012-04-19 12:34:02
【问题描述】:
我正在通过以下代码截取我上次查看的屏幕截图
//Image Code
UIImage *nextImage;
CGImageRef imgRef = CGBitmapContextCreateImage(UIGraphicsGetCurrentContext());
nextImage = [UIImage imageWithCGImage:imgRef];
CGImageRelease(imgRef);
CGContextRelease(UIGraphicsGetCurrentContext());
当我在控制台中显示图像时,我得到的 O/P 如下: UIImage: 0x929c760
问题就在这里,当将该 UIImage 转换为 NSData 时,我得到了 null。
我尝试过的事情是
//tried
NSData *data = UIImagePNGRepresentation(nextImage);
NSData *data2 = UIImageJPEGRepresentation(nextImage, 1.0);
【问题讨论】:
-
我正在将 CGContext 转换为 UIImage。现在 UIImage 将被转换为 NSData
-
你没有用任何图像填充你的图形上下文 - 所以它是空的 stackoverflow.com/questions/2200736/…
-
是的,我刚刚看到并且真的为我工作