2009-02-18 22 views
16

Aşağıdaki kod ile bitmap bağlamını almaya çalışıyorum:kCGColorSpaceGenericRGB iPhone'da kullanımdan kaldırıldı mı?

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 
} 

Bir uyarı diyor ki:

'kCGColorSpaceGenericRGB' is deprecated. bu colorSpace değişmez olduğu anlamına mı geliyor? Bu doğruysa, colorSpace kullanarak herhangi bir resmin renk verisini değiştiremeyiz. Ve o zaman görüntü nasıl işlenir?

cevap

35

Genel renk alanı kullanımdan kaldırılmıştır. Bunun yerine deneyin;

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); I love you cevap

+6

thx – Unreality

İlgili konular