【问题标题】:how to paint on live camera using Camera overlay view : issues in code如何使用相机叠加视图在实时相机上绘画:代码中的问题
【发布时间】:2012-06-04 05:36:27
【问题描述】:

我正在尝试在实时摄像头上绘制应用程序。为此,我创建了一个名为 PaintView 的带有 xib 的类,所有与绘制相关的功能都在其中运行。

我将paintview 添加到cameraoverlay 视图。视图已正确添加。但是当我触摸设备的屏幕时,应用程序无法绘制任何东西,并且日志显示以下错误

: CGContextSetLineWidth: 无效上下文 0x11b540

:CGContextSetRGBStrokeColor:无效上下文0x11b540

我添加子视图的代码是

// Insert the overlay
       
overlay = [[PaintView alloc] initWithNibName:@"PaintView" bundle:nil];

//overlay.pickerReference = self.imagePicker;

[self.imagePicker.cameraOverlayView addSubview:overlay.view];

[self.imagePicker.cameraOverlayView bringSubviewToFront:overlay.view];

[self.imagePicker.cameraOverlayView setBackgroundColor:[UIColor clearColor]];

//self.imagePicker.delegate = overlay;
        
[self presentModalViewController:self.imagePicker animated:YES];

请帮帮我,如何在实时相机上画画!!!

提前致谢。

编辑:在画图视图中,我正在创建图像视图,它的初始化方式类似于

drawImage = [[UIImageView alloc] init];

drawImage.frame = CGRectMake(20, 20, 320, 440);

[self.view addSubview:drawImage];

[self.view bringSubviewToFront:drawImage];

【问题讨论】:

  • 你是在 PaintView 的 drawRect: 方法中画图吗?
  • 是的,我正在绘制drawRect:方法,下面是代码
  • drawImage = [[UIImageView alloc] initWithImage:nil]; drawImage.frame = self.view.frame; [self.view addSubview:drawImage]; [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
  • 您在 drawImage.image 上调用 drawInRect,但您在 initWithImage 方法中将该图像设置为 nil。
  • 我改了,还是一样的问题,上下文无效是日志文件中的响应。

标签: iphone ios ios4


【解决方案1】:

您好,我已经解决了,

我弄错了,因为上下文不是必须使用的,它会产生问题。

我们需要使用 UIBezierPath,问题就解决了。我可以在实时摄像头上画画。

here the reference to the link.

是的.....

【讨论】:

    猜你喜欢
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多