2009-02-18 6 views
16

Ich versuche Bitmap Zusammenhang mit dem folgenden Code zu erhalten:kCGColorSpaceGenericRGB ist auf dem iPhone veraltet?

GContextRef MyCreateBitmapContext (int pixelsWide, int pixelsHigh) 
{ 
    CGContextRef context = NULL; 
    CGColorSpaceRef colorSpace; 
    void *   bitmapData; 
    int    bitmapByteCount; 
    int    bitmapBytesPerRow; 

    bitmapBytesPerRow = (pixelsWide * 4);       // 1 
    bitmapByteCount  = (bitmapBytesPerRow * pixelsHigh); 

    colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);// 2 
    bitmapData = malloc(bitmapByteCount);       // 3 
    if (bitmapData == NULL) 
    { 
     fprintf (stderr, "Memory not allocated!"); 
     return NULL; 
    } 

    context = CGBitmapContextCreate (bitmapData,      // 4 
            pixelsWide, 
            pixelsHigh, 
            8,  // bits per component 
            bitmapBytesPerRow, 
            colorSpace, 
            kCGImageAlphaPremultipliedLast); 
    if (context== NULL) 
    { 
     free (bitmapData);           // 5 
     fprintf (stderr, "Context not created!"); 
     return NULL; 
    } 

    CGColorSpaceRelease(colorSpace);        // 6 
    return context;             // 7 
} 

Eine Warnung sagt: 'kCGColorSpaceGenericRGB' is deprecated.

Dies bedeutet, dass colorSpace unveränderlich ist? Wenn das der Fall ist, können wir die Farbdaten von Bildern nicht mit colorSpace ändern. Und wie verarbeitet man das Bild dann?

Antwort

35

Der generische Farbraum ist veraltet. Stattdessen versuche es;

;

+6

thx für die Antwort Ich liebe dich – Unreality