2012-07-31 4 views
1
CGContextRef context = CGBitmapContextCreate(nil, 
     width, //if width More than 6002/4 
     height, 
     8, 
     width*4,//if width*4 > 6002 
     colorSpace, 
     kCGImageAlphaPremultipliedFirst |kCGBitmapByteOrder32Little); 

난 폭 * 4> (6002)은 큰 비트 맵을 감사를 구축하는 방법이IOS CGBitmapContextCreate 큰 비트 맵

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

하는 오류가있는 경우 (= 2,500 < 폭) 큰 비트 맵을 구축하고자.

답변

1

문제는 6002 바이트/행입니다. 각 픽셀은 여기에 4 바이트가 필요하기 때문에 6002는 나머지없이 4로 나눌 수 없습니다. 더 나은 픽셀 당 행 계산 :

size_t width = 1920; 
size_t height = 1080; 
CGContextRef context = CGBitmapContextCreate(
    NULL, 
    width, 
    height, 
    8, 
    width * 4, 
    colorSpace, 
    kCGImageAlphaPremultipliedFirst |kCGBitmapByteOrder32Little); 
+0

감사를 구축하는 몇 가지 코드를 줄 수있는, 이해할 수없는 – zt9788

0

새 bytesPerRow는 원본 이미지와 다릅니다. 새로운 bytesPerRow를 계산해야합니다.

bytesPerPixel *적인 targetWidth

당신은 정적 8

4. 색 공간 및 상대 bytesPerPixel에 대한 this를 참조하십시오 걸릴 수 없습니다.

+0

감사합니다,하지만 난 내가 지금 할 수있는, 당신은 나에게 매우 큰 비트 맵을 – zt9788

관련 문제