오류

2011-01-16 3 views
0

내가 여기오류

<Error>: Unsupported pixel description - 4 components, 8 bits-per-component, 32 bits-per-pixel 
<Error>: CGBitmapContextCreateWithDictionary: failed to create delegate. 
<Error>: CGImageDestinationAddImage image could not be converted to destination format. 
<Error>: CGImageDestinationFinalize image destination does not have enough images 

UIImageJPEGRepresentation(image, 0.5f); 내가 다운로드하고 데이터를 압축 코드 조각이다 사용하여 일부 JPEG 데이터를 압축하려고 다음과 같은 오류가 사용하여 JPEG 데이터를 압축 ...

ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:object.largeimage]]; 
[request startSynchronous]; 

NSData *imageData = [request responseData]; 

UIImage *image = [[UIImage alloc] initWithData:imageData]; 
NSData *compressedImageData = UIImageJPEGRepresentation(image, 0.5f); 

//If the data was compressed properly... 
if(compressedImageData) [compressedImageData writeToFile:filePath atomically:YES]; 

//If it wasn't... 
else [imageData writeToFile:filePath atomically:YES]; 

[image release]; 

if(request.responseStatusCode == 200) 
object.fullImageFilename = filePath; 

[request release]; 

[요청 릴리스];

여전히

답변

3

은 "적절한 대답은"확실하지 어떤 도움 :) 미리 감사드립니다,하지만 난

ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:object.largeimage]]; 
[request startSynchronous]; 

NSData *imageData = [request responseData]; 

UIImage *image = [[UIImage alloc] initWithData:imageData]; 
NSData *compressedImageData = UIImageJPEGRepresentation(image, 0.5f); 

//If the data was compressed properly... 
if(compressedImageData) [compressedImageData writeToFile:filePath atomically:NO]; 

//If it wasn't... 
else 
{ 
    UIGraphicsBeginImageContext(image.size); 
    [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 

    compressedImageData = UIImageJPEGRepresentation(newImage, 0.5f); 
    [compressedImageData writeToFile:filePath atomically:NO]; 
    [newImage release]; 
} 

[image release]; 

if(request.responseStatusCode == 200) 
    object.fullImageFilename = filePath; 

[request release]; 
+0

이 해결 방법은 나를 많이 저장 :) 관심있는 사람에 대한 해결 방법을 찾기 위해 관리 시간. 공유해 주셔서 감사합니다. 20.000 JPEG 사진의 배치에서 데이터베이스에 저장해야하는데이 오류는 약 250 개에 발생했습니다. 우리는 아직도 왜 그런지 모르겠다. – Bjinse