Ben*_*hen 2 iphone core-graphics quartz-2d
以下代码将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);
...
Run Code Online (Sandbox Code Playgroud)
编译为iPhone时此代码失败,因为iPhone版本的Core Graphics不包括CGImageDestinationRef.有没有办法CFImageRef使用本机iPhone框架和库保存到jpeg?我能想到的唯一选择是放弃Core Graphics并使用ImageMagick.
UIImage *myImage = [UIImage imageWithCGImage:image];
NSData *jpgData = UIImageJPEGRepresentation(myImage, 0.9f);
[jpgData writeToFile:...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1401 次 |
| 最近记录: |