iPhone CGContextRef CGBitmapContextCreate nicht unterstützte parameter-Kombination

In meiner Anwendung brauche ich zum ändern der Größe und zuschneiden-einige Bilder werden lokal gespeichert und online. Ich bin mit Trevor Harmon ' s tutorial implementiert UIImage+Resize.

Auf meinem iPhone 4(iOS 4.3.1) funktioniert alles OK, ich habe keine Probleme. Aber auf meinem iPhone 3G (iOS 3.2) die Größe und Ernte-Methoden funktionieren nicht für jedes Bild (die lokal gespeichert sind PNGs).
Dies ist die Ausgabe in der Konsole:

Tue Apr  5 02:34:44 Andreis-MacBook-Pro.local Puzzle[12453] <Error>: CGBitmapContextCreate:     unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 288 bytes/row.
Tue Apr  5 02:34:44 Andreis-MacBook-Pro.local Puzzle[12453] <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 288 bytes/row.
Tue Apr  5 02:34:44 Andreis-MacBook-Pro.local Puzzle[12453] <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 288 bytes/row.
Tue Apr  5 02:34:44 Andreis-MacBook-Pro.local Puzzle[12453] <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 288 bytes/row.

Dies ist die Ernte-Methode

- (UIImage *)croppedImage:(CGRect)bounds 
{
    CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds);
    UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);
    return croppedImage;
}

Die resize-Methode ist diese:

- (UIImage *)resizedImage:(CGSize)newSize
            transform:(CGAffineTransform)transform
       drawTransposed:(BOOL)transpose
 interpolationQuality:(CGInterpolationQuality)quality 
{
    CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width, newSize.height));
    CGRect transposedRect = CGRectMake(0, 0, newRect.size.height, newRect.size.width);
    CGImageRef imageRef = self.CGImage;

    CGContextRef bitmap = CGBitmapContextCreate(NULL,
                                            newRect.size.width,
                                            newRect.size.height,
                                            CGImageGetBitsPerComponent(imageRef),
                                            0,
                                            CGImageGetColorSpace(imageRef),
                                            CGImageGetBitmapInfo(imageRef));
    if(bitmap == nil)
        return nil;

    CGContextConcatCTM(bitmap, transform);

    CGContextSetInterpolationQuality(bitmap, quality);

    CGContextDrawImage(bitmap, transpose ? transposedRect : newRect, imageRef);

    CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap);
    UIImage *newImage = [UIImage imageWithCGImage:newImageRef];

    CGContextRelease(bitmap);
    CGImageRelease(newImageRef);

    return newImage;
}

Kann mir jemand erklären, wie ich dieses Problem?

Danke,
Andrei

InformationsquelleAutor Andrei Neacsu | 2011-04-04

Schreibe einen Kommentar