iphone中摄像头实时查看的水印图像

iphone中摄像头实时查看的水印图像,iphone,Iphone,提前特别感谢。。。。。。 我是iphone软件开发的乞丐 只是想了解如何使用cocoa以编程方式将实时水印图像添加到相机视图。不是一步一步地寻找(虽然那会很棒),而是或多或少地寻找我应该从哪里开始学习。是否有为此开发的框架。我希望使用XCode框架实现objective-C的原生功能,因为我希望最终在iPhone上实现这一功能。任何帮助都会很好。更新:以下是我的另一个答案,关于如何将此覆盖视图置于摄影机动画下: 海洛·拉詹德拉 我创建了一个简单的基于窗口的iPhone操作系统应用程序,为您提供了

提前特别感谢。。。。。。 我是iphone软件开发的乞丐


只是想了解如何使用cocoa以编程方式将实时水印图像添加到相机视图。不是一步一步地寻找(虽然那会很棒),而是或多或少地寻找我应该从哪里开始学习。是否有为此开发的框架。我希望使用XCode框架实现objective-C的原生功能,因为我希望最终在iPhone上实现这一功能。任何帮助都会很好。

更新:以下是我的另一个答案,关于如何将此覆盖视图置于摄影机动画下:

海洛·拉詹德拉

我创建了一个简单的基于窗口的iPhone操作系统应用程序,为您提供了一个非常简单的示例,说明应该如何使用相机拍摄照片、在相机模式下覆盖视图、调整图像大小和合并图像。这个项目实际上只有AppDelegate头文件和实现文件,可以很容易地在XCode中复制

下面是头文件:

//
//  CameraWatermarkAppDelegate.h
//  CameraWatermark
//
//  Created by Ivan Karpan on 1/16/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface CameraWatermarkAppDelegate : NSObject < UIApplicationDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate > {
    UIImageView *imageView;
    UIViewController *viewController;
    UIWindow *window;
}

@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UIViewController *viewController;
@property (nonatomic, retain) IBOutlet UIWindow *window;


@end

我希望这将为您提供一个起点。

嘿,拉詹德拉!如果我的答案对你足够有用,那就接受它。如果你不在评论中问你问题,我会看看我是否能帮上忙。伊万,我现在这是一篇老文章,但它非常有用,不过我确实有一个问题。。。叠加图像似乎在最终合并图像中偏移。有没有办法纠正这个问题?我认为这与缩放和相机的纵横比有关,但我不确定。有什么想法吗?在你的情况下,我会尝试对水印图像进行变换。如果你愿意,你可以发布你的问题,并附上足够让我开始一个新项目的代码片段,将代码粘贴到其中,然后进行处理。也许我能帮上忙。如果你决定发布这个问题,一定要给我发一条带有链接的消息。我在这里发布了一个问题和代码:谢谢你的帮助!!
//
//  CameraWatermarkAppDelegate.m
//  CameraWatermark
//
//  Created by Ivan Karpan on 1/16/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "CameraWatermarkAppDelegate.h"


const float WATERMARK_ALPHA = 0.5;


@implementation CameraWatermarkAppDelegate

@synthesize imageView, viewController, window;


- (void)applicationDidFinishLaunching:(UIApplication *)application {
    self.viewController = [[UIViewController new] autorelease];
    viewController.view.backgroundColor = [UIColor blackColor];

    // An image view to save to (and therefore display) the captured image
    self.imageView = [[UIImageView new] autorelease];
    imageView.frame = viewController.view.frame;
    [viewController.view addSubview:imageView];

    [window addSubview:viewController.view];

    UIImagePickerController *anImagePickerController = [UIImagePickerController new];
    anImagePickerController.delegate = self;
    anImagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

    {// This block of code is only needed in case you want your watermark to be displayed also during the shooting process
        UIImageView *anImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Watermark.png"]];
        anImageView.alpha = WATERMARK_ALPHA;
        anImageView.contentMode = UIViewContentModeTopLeft;
        anImageView.frame = viewController.view.frame;
        anImagePickerController.cameraOverlayView = anImageView;
        [anImageView release];
    }

    // From the very beginning we simply present the image picker controller
    [viewController presentModalViewController:anImagePickerController animated:NO];
    [anImagePickerController release];
}


- (void)dealloc {
    [imageView release];
    [viewController release];
    [window release];
    [super dealloc];
}

#pragma mark UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIGraphicsBeginImageContext(CGSizeMake(320, 480));
    // This is where we resize captured image
    [(UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage] drawInRect:CGRectMake(0, 0, 320, 480)];
    // And add the watermark on top of it
    [[UIImage imageNamed:@"Watermark.png"] drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeNormal alpha:WATERMARK_ALPHA];
    // Save the results directly to the image view property
    imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    // Dismiss the image picker controller and look at the results
    [picker dismissModalViewControllerAnimated:YES];
}


@end