내가 AVFoundation에서 잡는있어 이미지가 있습니다저장 CIImage는의 CGImage로 변환하여 오류를 발생
[stillImage captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
NSLog(@"image capture");
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
그때 처음 CIImage로 변환하여 이미지를 자르기 해요 :
beginImage = [CIImage imageWithCVPixelBuffer:CMSampleBufferGetImageBuffer(imageSampleBuffer) options:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], kCIImageColorSpace, nil]];
//first we crop to a square
crop = [CIFilter filterWithName:@"CICrop"];
[crop setValue:[CIVector vectorWithX:0 Y:0 Z:70 W:70] forKey:@"inputRectangle"];
[crop setValue:beginImage forKey:@"inputImage"];
croppedColourImage = [crop valueForKey:@"outputImage"];
을
CGImageRef cropColourImage = [context createCGImage:croppedColourImage fromRect:[croppedColourImage extent]];
UIImage *cropSaveImage = [UIImage imageWithCGImage:cropColourImage];
//saving of the images
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:[cropSaveImage CGImage] orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){
if (error) {
NSLog(@"ERROR in image save :%@", error);
} else
{
NSLog(@"SUCCESS in image save");
}
}];
그러나,이 예외 :
나는 그때 그것을 저장할 수 있도록의 CGImage이 다시 변환하려고 해요 오류가 :
ERROR in image save :Error Domain=ALAssetsLibraryErrorDomain Code=-3304 "Failed to encode image for saved photos." UserInfo=0x19fbd0 {NSUnderlyingError=0x18efa0 "Failed to encode image for saved photos.", NSLocalizedDescription=Failed to encode image for saved photos.}
나는 이미지가이 0x0 픽셀이라면이 발생할 수 있음을, 그리고의 CGImage에 CIImage에서 변환이 문제를 일으킬 수있는 다른 곳에서 읽었습니다. 어떤 아이디어?
감사합니다.
나는 이것을 저장하려고 시도하는 이미지에 치수가 없기 때문에 너비와 높이가 null로 보입니다. "2012-05-06 14 : 39 : 22.886 zApp [5108 : 707] 저장되는 이미지의 너비가 다음과 같습니다. (null) 2012-05-06 14 : 39 : 22.890 zApp [5108 : 707] 저장되는 이미지의 높이가 : (null) " – mrEmpty
NSLog 코드에서 오류가 발생했습니다. 저장하려고하는 이미지가 0x0 픽셀인지 확인할 수 있습니다. 그래서 나는 문제라고 생각하지만, 그것이 어떻게 될지 알 수 없다. – mrEmpty