cameraOverlayView 在 UIImagePickerController 中裁剪结果

发布于 2024-09-16 01:18:00 字数 210 浏览 3 评论 0原文

当我将 UIImagePickerControllercameraOverlayView 结合使用时,我可以从叠加视图中获取唯一的选定区域吗?

http://tinyurl.com/2fqy9nq

When I use UIImagePickerController with cameraOverlayView, can I get the only a selective region from my overlay view?

http://tinyurl.com/2fqy9nq

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2024-09-23 01:18:00
  1. 将 UIImageView 作为子项添加到您的cameraOverlayView。
  2. 创建尺寸为 320x480 的黑色 PNG 图像。在中间切一个矩形以产生一个孔(透明像素)。
  3. 将 PNG 图像分配给 UIImageView。

或者,您可以像这样覆盖您的cameraOverlayView的 - (void)drawRect:(CGRect)rect (未经我的测试):

// Request draw context
CGContextRef context = UIGraphicsGetCurrentContext();

// Draw background        
CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 1.0f);
CGContextFillRect(context, rect);

// Cut hole
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextFillRect(context, CGRectMake(40, 40, 100, 100);

我在我的 Faces 应用程序中做了类似的事情(http://faces.pixelshed.net/)。如果其中一个步骤似乎不清楚,请随时发表评论。

  1. Add an UIImageView as child to your cameraOverlayView.
  2. Create a black PNG image size 320x480. Cut a rectangle in the middle to produce a hole (transparent pixels).
  3. Assign the PNG image to the UIImageView.

Alternatively you could overwrite your cameraOverlayView's - (void)drawRect:(CGRect)rect like this (untested out of my head):

// Request draw context
CGContextRef context = UIGraphicsGetCurrentContext();

// Draw background        
CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 1.0f);
CGContextFillRect(context, rect);

// Cut hole
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextFillRect(context, CGRectMake(40, 40, 100, 100);

I have done something similar in my Faces app (http://faces.pixelshed.net/). Feel free to write a comment if one of the steps seems unclear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文