ios中图片的绘画和截图

CGImageCreateWithImageInRect截图和UIGraphicsGetImageFromCurrentImageContext绘画图片

使用CGImageCreateWithImageInRect截图

    UIImage *img1 = [UIImage imageNamed:@"123"];
//截取图片
CGImageRef imgSmall = CGImageCreateWithImageInRect(img1.CGImage, CGRectMake(100, 100, 100, 100));
UIImage *img2 = [UIImage imageWithCGImage:imgSmall];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img2];
[imgView setFrame:CGRectMake(0, 100, 100, 100)];
[self.view addSubview:imgView];

使用UIGraphicsGetImageFromCurrentImageContext绘画图片

UIImage *img1 = [UIImage imageNamed:@"123"];
UIImage *img2 = [UIImage imageNamed:@"123"]; //开始绘画,设置画布的大小
UIGraphicsBeginImageContext(CGSizeMake(img1.size.width, img1.size.height * 2));
//将图片画进去
[img1 drawInRect:CGRectMake(0, 0, img1.size.width, img1.size.height)];
[img2 drawInRect:CGRectMake(0,img1.size.height, img1.size.width, img1.size.height)];
//就画布中的内容,放置到图片中
UIImage *img3 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//在视图中显示
UIImageView *imgView = [[UIImageView alloc] initWithImage:img3];
[imgView setFrame:CGRectMake(0, 100, 100, 100)];
[self.view addSubview:imgView];

ios中图片的绘画和截图的更多相关文章

  1. IOS中图片拉伸技巧与方法总结(转载)

    以下内容转载自:http://my.oschina.net/u/2340880/blog/403996 IOS中图片拉伸技巧与方法总结 一.了解几个图像拉伸的函数和方法 1.直接拉伸法 简单暴力,却是 ...

  2. 谈谈 iOS 中图片的解压缩

    原文 对于大多数 iOS 应用来说,图片往往是最占用手机内存的资源之一,同时也是不可或缺的组成部分.将一张图片从磁盘中加载出来,并最终显示到屏幕上,中间其实经过了一系列复杂的处理过程,其中就包括了对图 ...

  3. 【转】谈谈 iOS 中图片的解压缩

    转自:http://blog.leichunfeng.com/blog/2017/02/20/talking-about-the-decompression-of-the-image-in-ios/ ...

  4. IOS中图片加载的一些注意点

    图片的加载: [UIImage imageNamed:@"home"] //加载 png图片 在ios中获取一张图片只需要写图片名即可 不需要写后缀 默认都是加载.png的图片 但 ...

  5. ios中图片拉伸用法

    - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCap ...

  6. iOS开发:iOS中图片与视频一次性多选 - v2m

    一.使用系统的Assets Library Framework这个是用来访问Photos程序中的图片和视频的库.其中几个类解释如下 ALAsset ->包含一个图片或视频的各种信息 ALAsse ...

  7. iOS中图片动画的三种模式及基本的代码实现

    -(void)play { //第一种图片动画模式 头尾方式 //头尾方式 [UIView beginAnimations:nil context:nil];//动画开始 [UIView setAni ...

  8. iOS中图片拉伸,类似Android中的点9图片

    UIImage* img=[UIImage imageNamed:@"name.png"];//原图 UIEdgeInsets edge=UIEdgeInsetsMake(, , ...

  9. ios中图片旋转

    @interface ViewController () { UIImageView *_imageview; BOOL flag; } @end @implementation ViewContro ...

随机推荐

  1. LINUX防火墙firewall、iptables

    (1) 重启后永久性生效: 开启: systemctl enable iptables.service'.ln -s '/usr/lib/systemd/system/iptables.service ...

  2. SOSEx ReadMe

    Quick Ref:--------------------------------------------------bhi [filename] BuildHeapIndex - Builds a ...

  3. jdk各个版本

    http://www.cnblogs.com/langtianya/p/3757993.html

  4. 使用SeaJS实现模块化JavaScript开发

    前言 SeaJS是一个遵循CommonJS规范的JavaScript模块加载框架,可以实现JavaScript的模块化开发及加载机制.与jQuery等JavaScript框架不同,SeaJS不会扩展封 ...

  5. uva 1203 - Argus

    简单的优先队列的应用: 代码: #include<queue> #include<cstdio> using namespace std; struct node { int ...

  6. keil C51中建立多文件时,变量重复定义的解决

    c/c++语言中有很多地方要用到extern,但是如果没有真正的了解它的意义,会给编程带来很大的麻烦,为了使大家少走弯路,特祥细的说明一下. 对于比较小的程序,一般只有一个c文件和一个头文件,全局变量 ...

  7. Delphi能通过SSH登录Linux,连接MYSQL取数么?像Navicat一样

    百度随时就能搜,你就懒得搜下.http://tieba.baidu.com/p/671327617 Ssh tunnel通常能实现3种功能1) 加密网络传输2) 绕过防火墙3) 让位于广域网的机器连接 ...

  8. -_-#gb2312解码

    百度视频采用gb2312编码,点击出来的链接中的中文转成了gb2312,而gb2312无法解码 如果链接中的中文直接utf-8编码,就没问题,但编辑后台有长度限制 关于URL编码 JS(Unicode ...

  9. js或者cs代码拼接html

    一:使用到的jQuery 文档操作方法 html() 设置或返回匹配的元素集合中的 HTML 内容. append() 向匹配元素集合中的每个元素结尾插入由参数指定的内容. empty() 删除匹配的 ...

  10. Selenium如何实现dropbar移动

    遇到这个拖拽的dropbar,如何实现呢,, 经过网上查找,可以用Action的方式实现或者js来控制 原理:移动按钮的同时,数字也随着变化 解决方法:1.最简单的就是直接在文本框输入相应的数字 2. ...