【发布时间】:2013-04-17 14:36:17
【问题描述】:
我想做的是以下。用户可以使用 iPhone 相机拍照。拍照后,他们将在所拍照片的顶部放置另一张图像。放置在顶部的图像也应旋转 25°。除了旋转之外,我还需要将顶部的图像降低到拍摄照片下方一点。 你可以在这里看到我的意思。
我有以下。
-(UIImage *)drawImage:(UIImage*)profileImage withBadge:(UIImage *)badge
{
UIGraphicsBeginImageContextWithOptions(profileImage.size, NO, 0.0f);
[profileImage drawInRect:CGRectMake(0, 0, profileImage.size.width, profileImage.size.height)];
[badge drawInRect:CGRectMake(profileImage.size.width - badge.size.width, profileImage.size.height - badge.size.height,badge.size.width,badge.size.height)];
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultImage;
}
-(void)captureImage {
UIImage *img1 = [cropFilter imageFromCurrentlyProcessedOutput];
UIImage *img2 = [UIImage imageNamed:@"genkonstage.jpg"];
UIImage *img = [self drawImage:img1 withBadge:img2];
//UIImage *img = [cropFilter imageFromCurrentlyProcessedOutput];
[stillCamera.inputCamera unlockForConfiguration];
[stillCamera stopCameraCapture];
[self removeAllTargets];
staticPicture = [[GPUImagePicture alloc] initWithImage:img
smoothlyScaleOutput:YES];
谁能帮帮我?
【问题讨论】:
-
您的 drawImage:withBadge: 方法是否符合预期?似乎它应该致力于将两个图像混合在一起
-
是的,它将图像放在另一个之上。但我也想旋转它。我找不到使用 UIImage 的方法。
-
是的,在这种情况下,最好在上下文中执行此类操作(旋转等)。看看我的答案
标签: iphone ios objective-c uiimageview uiimage