是否可以在 iPhone 上保存带有 Core Graphics 的图像?
以下代码将 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。有没有办法使用本机 iPhone 框架和库将 CFImageRef
保存为 jpeg?我能想到的唯一选择是放弃 Core Graphics 并使用 ImageMagick。
The following code converts a PDF page into a JPEG. It runs as expected on 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);
...
This code fails when compiled for iPhone because the iPhone version of Core Graphics does not include CGImageDestinationRef
. Is there any way to save CFImageRef
to a jpeg using the native iPhone frameworks and libraries? The only alternative I can think of is to ditch Core Graphics and use ImageMagick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)