下面的代码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:...
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top