风的研发日记


欢迎来到我的个人站~


图像相关

获得屏幕图像

+ (UIImage *)imageFromView: (UIView *) theView{
    UIGraphicsBeginImageContext(theView.frame.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [theView.layer renderInContext:context];
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
}

获得某个范围内的屏幕图像

+ (UIImage *)imageFromView: (UIView *) theView   atFrame:(CGRect)r{
    UIGraphicsBeginImageContext(theView.frame.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    UIRectClip(r);
    [theView.layer renderInContext:context];
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return  theImage;
}

在程序中如何把两张图片合成为一张图片

+ (UIImage *)addImage:(UIImage *)image1 toImage:(UIImage *)image2 {
    UIGraphicsBeginImageContext(image2.size);
    
    // Draw image1
    [image1 drawInRect:CGRectMake(0, 0, image1.size.width, image1.size.height)];

    [image2 drawInRect:CGRectMake(0, 0, image2.size.width, image2.size.height)];
    
    UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return resultingImage;
}
最近的文章

IDEA+Maven+SpringMVC+Spring+Mybatis SSM集成记录

前言这段时间自己开始转 java后台,开始的第一个项目需要搭建 SSM框架,由于是 mac系统,被 eclipse虐了无数遍,最终转战 IDEA,使用 IDEA搭建完成了自己的第一个 SSM框架,特地在此记录一下;github Demo地址工具介绍 IDEA 2017 java SDK 1.7.0_79 Tomcat 7.0.79 Maven 3.5 SpringMVC ,Spring 4.3.7 Mybatis 3.4.2创建 Maven工程新建工程勾选上 Creat fro...…

java继续阅读
更早的文章

NSString 相关笔记

1.截取字符串 NSString*string =@"sdfsfsfsAdfsdf"; string = [string substringToIndex:7];//截取掉下标7之后的字符串 NSLog(@"截取的值为:%@",string); [string substringFromIndex:2];//截取掉下标2之前的字符串 NSLog(@"截取的值为:%@",string); 2.匹配字符串 NSString*string =@...…

iOS继续阅读