2012-09-22 1 views
0

-90도를 사용하여 CGContextRef의 내용을 회전하고 싶습니다. 일부 코드를 발견했지만 제대로 작동하지 않습니다.CGContextRef 회전이 작동하지 않습니다.

CGContextRef tempColorRef = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, 
                bytesPerRow, colorspace, 
                kCGImageAlphaPremultipliedLast); 
CGImageRef colorImageRef = CGBitmapContextCreateImage(colorContextRef); 
CGContextTranslateCTM(tempLayerRef, width/2, height/2); 
CGContextRotateCTM(tempLayerRef, DegreesToRadians(-90)); 
CGContextScaleCTM(tempColorRef, 1.0, -1.0); 
CGContextDrawImage(tempColorRef, CGRectMake(-width/2, -height/2, width, height), colorImageRef); 
CGImageRelease(colorImageRef); 

colorContextRef = tempColorRef; 

누구나 도와주세요.

+2

"올바르게 작동하지 않음"이란 무엇을 의미합니까? 당신은 비강 악마 또는 무엇을 경험합니까? –

+0

내용물이 사라졌습니다. –

+0

수학 부분이 엉망이되어 틀림없이 문맥을 그릴 것이라고 확신합니다. 스케일 부분을 제거하면 어떨까요? –

답변

0

H2CO3의 의견에 따르면 다양한 변형을 시도했습니다.

내 잘못이었습니다. widthheightsize_t 변수이므로 마이너스 값을 유지할 수 없습니다. 다음 명령에서 오류가 발생했습니다.

CGRectMake(-width/2, -height/2, width, height)

지금은 잘 작동합니다.