zoukankan      html  css  js  c++  java
  • 屏幕截图

    1、获得屏幕图像

    - (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;//[self getImageAreaFromImage:theImage atFrame:r];

    }

    2、将图像保存到图库中

       UIImageWriteToSavedPhotosAlbum([imageView image], nilnil,nil);

           UIAlertView *alert = [[UIAlertView allocinitWithTitle:@"存储照片成功"

                                                     message:@"您已将照片存储于图片库中,打开照片程序即可查看。"

                                                     delegate:self

                                             cancelButtonTitle:@"OK"

                                             otherButtonTitles:nil];

           [alert show];

           [alert release];

  • 相关阅读:
    抽象类和接口的区别
    排序之快速排序(quickSort)
    互联网协议入门(1)
    字符串的操作String
    Java笔试题之SQL语句(单表)
    求职之Java开发所需技能
    【更新完毕啦!】一篇完整的产品体验报告处女作
    阿里2015暑期实习生业务型产品笔试题(附部分参考答案)
    滴滴笔试题(附我的答案)
    【面试】蘑菇街产品运营二面&结果
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3437153.html
Copyright © 2011-2022 走看看