5
iPhoneアプリケーションを開発していて、2つのUIImage(leftImageとrightImage)をマージしたいと思います。誰もそれらの間にラインを持たないで行う方法を提案することはできますか?iPhone SDKのObjective-Cで2つのUIImageオブジェクトをマージする方法
- (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;
}
をしかし、それは、2つの画像間の小さな行を作成します。
私は現在、これをやっています。 Splitcamと同じように、この区切り文字は欲しくない。
どうすればいいですか?
それでも動作しないと、それらの間に線ができます。 –