在iphone的照相机视图的实时水印图象

在iphone的照相机视图的实时水印图象

本文介绍了在iphone的照相机视图的实时水印图象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

特别感谢提前......
我是iphone软件开发的先驱者。

Special Thanks in advance......I m the beggininer in iphone software development.

只是想看看如何使用cocoa以编程方式将水印图像实时添加到摄像机视图中。不是一步一步寻找(虽然那会很棒),但或多或​​少地寻找我应该开始学习如何的地方。是否开发了适用于此的框架。想要使用XCode框架本地使用Objective-C,因为我想最终在iPhone上使用它。任何帮助都会很棒。

Just looking for how to programmatically add real time a watermark image to camera view using cocoa. Not looking for a step by step ( although that would awesome ), but more or less looking for where I should start looking to learn how. Are there frameworks developed to work for this. Would like something native to objective-C using XCode framework because I would like to eventually give this a go on the iPhone. Any help would be great.

推荐答案

更新:这是我的另一个答案,关于这个叠加视图如何能够放在相机动画下:

UPDATE: here's my other answer about how this overlay view can be put under the camera animations: camera overlay view - just for preview?

Helo Rajendra!

Helo Rajendra!

我创建了一个简单的基于Window的iPhone OS应用程序你是一个非常简单的例子,说明用相机捕捉照片的方式和方法,在相机模式下叠加视图,调整大小和合并图像。这个项目实际上只有AppDelegate头和实现文件,可以在XCode中轻松复制。

I've created a simple Window-based iPhone OS Application to give you a very simple example on what and how should be done to capture photos with camera, overlay views in camera mode, resize and merge images. This project is actually has only AppDelegate header and implementation files and can be easily reproduced in 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

我希望这将作为一个起点。

I hope this will serve you as a starting point.

这篇关于在iphone的照相机视图的实时水印图象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 21:21