自动将图像帧添加到拍摄的屏幕截图 [英] Automatically add Image frame to taken screenshot

查看:103
本文介绍了自动将图像帧添加到拍摄的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动将图像帧添加到拍摄的屏幕截图中.这是我用来截取屏幕截图的代码.有任何想法将这张图片放在拍摄的屏幕快照上吗?

I would like to automatically add a image frame to a taken screenshot. Here´s the code I´m using to take the screenshot. Any Ideas to put this image around the taken screenshot?

为完整起见:我想给用户一个选项,可以在Twitter或Facebook上与该框架共享漂亮的屏幕截图.

For the completeness: I want to give the user a option to share this beautiful screenshot with it´s frame on Twitter or Facebook.

顺便说一句:那是我作为程序员的第一个应用程序,所以请给我完整的解决方案或教程以完成此操作...

BTW: That´s my first app as programmer, so please give me full solution or a tutorial to do this…

屏幕截图: http://techstern.de/app/screenshot1.png
我要放置的框架: http://oi45.tinypic.com/2qvv2tv.jpg
原型:访问 http://i.stack.imgur.com/hg1nW.png

Screenshot: http://techstern.de/app/screenshot1.png
Frame I want to put around it: http://oi45.tinypic.com/2qvv2tv.jpg
Prototype: visit http://i.stack.imgur.com/hg1nW.png

代码

- (UIImage *)screenshot
{
    UIGraphicsBeginImageContext(self.view.frame.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

*因为我刚刚注册,所以我在本文中最多可以放置2个链接.

*I can´t put more than 2 links in this article because I´ve just signed up.

推荐答案

我在评论中提出的解决方案.

The solution I proposed in the comments.

- (UIImage *)screenShot {
    UIImage *frame = [UIImage imageNamed:@"frame"];

    UIGraphicsBeginImageContext(frame.size);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    [frame drawAtPoint:CGPointZero blendMode:kCGBlendModeOverlay alpha:1.0];

    CGContextTranslateCTM(ctx, xCordinateOfScreenshotInFrame, yCordinateOfScreenshotInFrame);
    [self.view.layer renderInContext:ctx];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}

这篇关于自动将图像帧添加到拍摄的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆