2012-02-14 4 views
0

광원 주위의 구면의 색을 변경하는 기능을 찾고 있습니다. 지금은 Color에서 CGImage를 만들고 PNG로 마스킹하여이 작업을 수행합니다. 이 작동하지만, 색상을 변경할 때마다 나는 정말 느린 전체 이미지를 다시 그릴 필요가있다.Tint UIImage 다시 그리기하지 않고

이미지를 다시 그려 넣지 않고 색조를 칠할 가능성이 있습니까? 당신의 도움이

에 대한

덕분에이 구체를 만들어 내 현재의 방법입니다

사람이 함수 호출이 느린, 나는 대답을 주셔서 감사합니다 것 인 하우투 측정을 알고 자하는 경우
+ (UIImage *)imageWithColor:(UIColor *)color andImage:(UIImage *)image 
{ 
    // create Image from Color 
    CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height); 
    UIGraphicsBeginImageContext(rect.size); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColorWithColor(context,[color CGColor]); 
    CGContextFillRect(context, rect); 
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 

    // mask color 
    CGImageRef actualMask = CGImageMaskCreate(CGImageGetWidth(image.CGImage), 
               CGImageGetHeight(image.CGImage), 
               CGImageGetBitsPerComponent(image.CGImage), 
               CGImageGetBitsPerPixel(image.CGImage), 
               CGImageGetBytesPerRow(image.CGImage), 
               CGImageGetDataProvider(image.CGImage), NULL, false); 


    CGImageRef masked = CGImageCreateWithMask([img CGImage], actualMask); 
    CGImageRelease(actualMask); 
    UIImage * retImage = [UIImage imageWithCGImage:masked]; 
    CGImageRelease(masked); 
    return retImage; 
} 

. 나는 계기로 App Frame Rate를 실행했고 Color를 변경하면서 초당 약 3 프레임을 얻었습니다.)

답변

0

Time Profiler 옵션으로 Instruments를 실행해야합니다.

관련 문제