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];

  • 相关阅读:
    js页面问题--(ing)
    tomcat9以后对,请求消息头的严格字符要求
    linux常用命令--(不断更新)
    怎么用wireshark看抓包文件
    关于h2的启动问题
    VUE-02 基本指令
    RecyclerView设置空视图
    SpringBoot-JPA删除不成功,只执行了查询语句
    关于RecyclerView(二)设置EmptyView
    关于RecyclerView(一)基本使用
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3437153.html
Copyright © 2011-2022 走看看