小编Ari*_*.R.的帖子

从CGImageRef创建的UIImage因UIImagePNGRepresentation而失败

我正在使用以下代码来裁剪并创建一个更大的UIImage.我已经将问题与CGImageCreateWithImageInRect()函数隔离开来,它似乎没有按照我想要的方式设置一些CGImage属性.:-)问题是调用函数UIImagePNGRepresentation()失败返回nil.

CGImageRef origRef = [stillView.image CGImage];
CGImageRef cgCrop = CGImageCreateWithImageInRect( origRef, theRect);
UIImage *imgCrop = [UIImage imageWithCGImage:cgCrop];
Run Code Online (Sandbox Code Playgroud)

...

NSData *data = UIImagePNGRepresentation ( imgCrop);
Run Code Online (Sandbox Code Playgroud)

- libpng错误:没有IDAT写入文件

知道UIImage中裁剪矩形可能有什么不妥或替代吗?非常感谢!

iphone uiimage cgimage nsdata

13
推荐指数
1
解决办法
9095
查看次数

标签 统计

cgimage ×1

iphone ×1

nsdata ×1

uiimage ×1