是否有可能保存图像与iPhone核芯显卡?
-
24-09-2019 - |
题
下面的代码PDF页面转换为JPEG。它运行正常雪豹:
...
//get the image from the bitmap context
CGImageRef image = CGBitmapContextCreateImage(outContext);
//create the output destination
CGImageDestinationRef outfile = CGImageDestinationCreateWithURL(fileUrl, kUTTypeJPEG, 1, NULL);
//add the image to the output file
CGImageDestinationAddImage(outfile, image, NULL);
CGImageDestinationFinalize(outfile);
...
在编译时为iPhone,因为核芯显卡的iPhone版本不包括CGImageDestinationRef
此代码失败。有没有什么办法CFImageRef
保存到使用iPhone内置软件的框架和库JPEG?唯一的选择我能想到的是沟核心图形和使用的ImageMagick。
解决方案
UIImage *myImage = [UIImage imageWithCGImage:image];
NSData *jpgData = UIImageJPEGRepresentation(myImage, 0.9f);
[jpgData writeToFile:...
不隶属于 StackOverflow