以下代码将 PDF 页面转换为 JPEG。它在 Snow Leopard 上按预期运行:
...
//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 版本的 Core Graphics 不包含CGImageDestinationRef
. 有没有办法CFImageRef
使用原生 iPhone 框架和库保存到 jpeg?我能想到的唯一选择是放弃 Core Graphics 并使用 ImageMagick。