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

関連する問題