2014-11-06 8 views
1

누구나 iOS 8 용으로이 코드를 업데이트하는 방법을 알고 계십니까? 이 오류 메시지가 점점 오전 : 행당iOS 8 CGContextRef 지원되지 않는 매개 변수 조합

CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaPremultipliedFirst; 4294967289 bytes/row.

CGContextRef CreateBitmapContenxtFromSizeWithData(CGSize s, void* data) 
{ 
    int w = s.width, h = s.height; 
    int bitsPerComponent = 8; 
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
    int components = 4; 
    int bytesPerRow = (w * bitsPerComponent * components + 7)/8; 

    CGContextRef result = CGBitmapContextCreate(data, w, h, 8, bytesPerRow, colorSpace, (CGBitmapInfo)kCGImageAlphaPremultipliedFirst); 
    CGColorSpaceRelease(colorSpace); 
    return result; 
} 
+0

아무도이를 수행하는 방법을 모릅니다. – mikomi

답변

0

바이트는 위의 코드에서 잘못 계산됩니다.

행 당 바이트를 계산하려면 이미지의 너비와 픽셀 당 비트 수를 곱하면됩니다.이 경우 4가됩니다. RGB에 저장된 이미지 데이터에 data 점, 당신은 픽셀 당 3 바이트가있는 경우

int bytesPerRow = w * 4; 

는하지만주의해야합니다. 알파 채널이 생략되도록 CGImageAlphaInfo.NoneSkipFirst 플래그를 마지막 매개 변수로 CGBitmapContextCreate에 전달해야합니다.