我有一个带有很多蒙版图像的应用程序。出于性能考虑,我需要在磁盘上生成这些蒙版图像,然后将它们合并到应用程序中(它们将按需上传,而不是动态蒙版,因为它已经完成了)。
我正在使用这种编码
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/Test_%d.png",i]];
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/Test_%d.jpg",i]];
// Write a UIImage to JPEG with minimum compression (best quality)
// The value 'image' must be a UIImage object
// The value '1.0' represents image compression quality as value from 0.0 to 1.0
[UIImageJPEGRepresentation([self maskImageWithStroke:image withMask:maskImage], 1.0) writeToFile:jpgPath atomically:YES];
// Write image to PNG
[UIImagePNGRepresentation([self maskImageWithStroke:image withMask:maskImage]) writeToFile:pngPath atomically:YES];
它适用于我的中间图像,但不适用于最终图像。
下面是我使用的多个 mask 和 blan 的过程:
拍摄图像并对其进行遮罩以获得 maskedImage
列表项获取掩码并将其调整为更大一点:bigMask
混合 maskedImage 和 largemask 以让 biggrMask 描边 maskedStrokedImage (这是我发现在不规则蒙版图像上添加不规则描边的唯一方法)
用更大的Mask 遮罩 maskedStrokedImage 以获得我的最终结果。
问题是:保存在步骤 1 中获得的图像是可以的:我有一个 JPG 和 PNG,正是我需要的。
我的目标是将第 4 步的结果保存到磁盘,但结果是 imahe 显示了笔画的某些部分,其余部分是白色的......
知道为什么我无法将步骤 4 保存到磁盘吗?