faster way to draw an image

Posted by iHorse on Stack Overflow See other posts from Stack Overflow or by iHorse
Published on 2010-04-16T19:30:50Z Indexed on 2010/04/16 19:33 UTC
Read the original article Hit count: 395

Filed under:
|
|
|

im trying to combine two images into a single image. unfortunately this has to be done very quickly in response to a user sliding a UISlider. i can combine the two images into a single image no problem. but the way I'm doing it is horribly slow. the sliders stick and jump rather frustratingly. i don't think i can throw the code into a background thread because i would run out of threads to quickly. i haven't actually tired that yet. below is my code. any ideas on how to speed it up would be helpful.

UIGraphicsBeginImageContext(CGSizeMake(bodyImage.theImage.image.size.width * 1.2, bodyImage.theImage.image.size.height * 1.2));

[bodyImage.theImage.image drawInRect: 
 CGRectMake(-2 + ((bodyImage.theImage.image.size.width * 1.2) - bodyImage.theImage.image.size.width)/2, 
            kHeadAdjust, 
            bodyImage.theImage.image.size.width * bodyImage.currentScale, 
            bodyImage.theImage.image.size.height * bodyImage.currentScale)];

if(isCustHead)
{
    [Head.theImage.image drawInRect: CGRectMake((bodyImage.theImage.image.size.width * 1.2 - headWidth)/2 - 11,
                                                0, 
                                                headWidth * 0.92, 
                                                headWidth * (Head.theImage.image.size.height/Head.theImage.image.size.width) * 0.92)];
}
else 
{
    [Head.theImage.image drawInRect: CGRectMake((bodyImage.theImage.image.size.width * 1.2 - (headWidth * defaultHeadAdjust))/2 - 10,
                                                0, 
                                                (headWidth * defaultHeadAdjust * 0.92), 
                                                (headWidth * defaultHeadAdjust) * (Head.theImage.image.size.height/Head.theImage.image.size.width) * 0.92)];
}

drawSurface.theImage.image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

© Stack Overflow or respective owner

Related posts about fast

Related posts about image