ユーザーがカメラから写真を撮るたびに、複数の画像を 1 つずつステッチする必要があるアプリを開発しています。
これは、2つの画像をマージするために使用しているものです。
[self performSelector:@selector(joinImages:secondImage:) withObject:firstimage withObject:imageCaptured];
- (UIImage *)joinImages:(UIImage *)im1 secondImage:(UIImage *)im2
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//Joins 2 UIImages together, stitching them horizontally
CGSize size = CGSizeMake(im1.size.width+im2.size.width, im2.size.height);
UIGraphicsBeginImageContext(size);
CGPoint image1Point = CGPointMake(0, 0);
[im1 drawAtPoint:image1Point];
CGPoint image2Point = CGPointMake(im1.size.width,0);
[im2 drawAtPoint:image2Point];
UIImage* finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
firstimage=finalImage;// final images updated everytime
[pool release];
return finalImage;
}
しかし、これを iPhone で実行するとメモリ警告が表示され、iPod では問題なく動作します。
また、iPhoneの場合は画像がトリミングされます。
この問題を解決するために私にできることは何でも。
ありがとう..