2

次のコードは、PDFページをJPEGに変換します。SnowLeopardでは期待どおりに動作します。

...
//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バージョンのCoreGraphicsにはが含まれていないため、iPhone用にコンパイルするとこのコードは失敗しますCGImageDestinationRefCFImageRefネイティブのiPhoneフレームワークとライブラリを使用してjpegに保存する方法はありますか?私が考えることができる唯一の選択肢は、コアグラフィックスを捨ててImageMagickを使用することです。

4

1 に答える 1

9
UIImage *myImage = [UIImage imageWithCGImage:image];
NSData *jpgData = UIImageJPEGRepresentation(myImage, 0.9f);
[jpgData writeToFile:...
于 2010-03-03T11:45:37.103 に答える