2009-02-18 10 views
16

Estoy tratando de obtener el contexto de mapa de bits con el siguiente código:kCGColorSpaceGenericRGB está en desuso en iPhone?

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 
} 

Una advertencia dice: 'kCGColorSpaceGenericRGB' is deprecated.

¿Quiere decir esto que colorSpace es inmutable? Si eso es cierto, no podremos cambiar los datos de color de ninguna imagen usando colorSpace. ¿Y cómo procesar la imagen?

Respuesta

35

El espacio de color genérico está en desuso. En cambio, intenta;

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

+6

Gracias por la respuesta Te amo – Unreality

Cuestiones relacionadas