2012年6月30日 星期六

Combine two Image

-(UIImage*)mergeImage:(UIImage*)first withImage:(UIImage*)second
{
    // build merged size
    CGSize mergedSize = CGSizeMake(Main_Pic_Width * 2 + 10, Main_Pic_Height);
    
    // capture image context ref
    UIGraphicsBeginImageContext(mergedSize);
    
    //Draw images onto the context
    [first drawInRect:CGRectMake(0, 0, Main_Pic_Width, Main_Pic_Height)];
    [second drawInRect:CGRectMake(Main_Pic_Width + 10, 0, Main_Pic_Width, Main_Pic_Height)]; 
    
    // assign context to new UIImage
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    
    // end context
    UIGraphicsEndImageContext();
    
    return newImage;
}

沒有留言:

張貼留言