2010-03-03 3 views
2

다음 코드는 PDF 페이지를 JPEG로 변환합니다. 그것은 스노우 레오파드 (Snow Leopard)에서 예상대로 실행 : 코어 그래픽의 아이폰 버전이 CGImageDestinationRef 포함되어 있지 않기 때문에 아이폰 용으로 컴파일 할 때Core Graphics로 이미지를 iPhone에 저장할 수 있습니까?

... 
//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 프레임 워크 및 라이브러리를 사용하여 jpeg에 CFImageRef을 저장할 수있는 방법이 있습니까? 내가 생각할 수있는 유일한 대안은 Core Graphics를 도려내고 ImageMagick을 사용하는 것입니다.

답변

9
UIImage *myImage = [UIImage imageWithCGImage:image]; 
NSData *jpgData = UIImageJPEGRepresentation(myImage, 0.9f); 
[jpgData writeToFile:... 
관련 문제