Tôi đang phát triển một ứng dụng iPhone và tôi muốn kết hợp hai UIImages (leftImage và rightImage). Bất cứ ai có thể đề nghị làm thế nào để làm điều đó mà không có dòng ở giữa chúng?Làm thế nào để hợp nhất hai đối tượng UIImage trong Objective-C trong iPhone SDK
Tôi hiện đang làm điều này:
- (UIImage*)mergeImage:(UIImage*)first withImage:(UIImage*)second
{
// get size of the first image
CGImageRef firstImageRef = first.CGImage;
CGFloat firstWidth = CGImageGetWidth(firstImageRef);
CGFloat firstHeight = CGImageGetHeight(firstImageRef);
// get size of the second image
CGImageRef secondImageRef = second.CGImage;
CGFloat secondWidth = CGImageGetWidth(secondImageRef);
CGFloat secondHeight = CGImageGetHeight(secondImageRef);
// build merged size
CGSize mergedSize = CGSizeMake((firstWidth+secondWidth), MAX(firstHeight, secondHeight));
// capture image context ref
UIGraphicsBeginImageContext(mergedSize);
//Draw images onto the context
[first drawInRect:CGRectMake(0, 0, firstWidth, firstHeight)];
//[second drawInRect:CGRectMake(firstWidth, 0, secondWidth, secondHeight)];
[second drawInRect:CGRectMake(firstWidth, 0, secondWidth, secondHeight) blendMode:kCGBlendModeNormal alpha:1.0];
// assign context to new UIImage
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
// end context
UIGraphicsEndImageContext();
return newImage;
}
Nhưng nó tạo ra một dòng nhỏ giữa hai hình ảnh. Tôi không muốn dấu phân cách này, giống như cách Splitcam thực hiện.
Tôi làm cách nào để thực hiện việc này?
Nó không hoạt động vẫn cung cấp một đường thẳng giữa chúng. –