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. iOS: 学习笔记, Swift与Objective-C混用总结

    Swift与Objective-C交互总结 在Swift中使用Objective-C(简单) 在创建OjbC文件时, XCode会提示创建XXX-Bridging-Header.h文件, 创建之 在创 ...

  2. VS-FluentData 单元测试

    1. 使用VS2013建立一个控制台工程: using System; using System.Collections.Generic; using System.Linq; using Syste ...

  3. id类型

    id类型 在Objective-C 中,id 类型是一个独特的数据类型.在概念上,类似Java 的Object 类,可以转换为任何数据类型.换句话说,id 类型的变量可以存放任何数据类型的对象.在内部 ...

  4. Data Guard配置后续检查

    Data Guard配置后续检查 1.打开生产端节点192.166.1.190上的数据库实例: SQL>startup; 2.打开容灾端节点192.166.1.60上的数据库实例: SQL> ...

  5. PHP 7.0 安装使用与性能监测!

    PHP 7.0发布,网上关于新版的介绍很多,介于 7.0 在正式发布之前已经发过若干个 Beta.8个 RC,应该不会出现重大问题.今日我将一台机器升级至 PHP 7.0 并将有关信息记录如下. 本人 ...

  6. CSS实现文字竖排 DIV CSS文字垂直竖列排版显示如何实现?

    DIV CSS实现文字竖排排版显示兼容各大浏览器,让文字垂直竖列排版布局. 有时我们需要一段文字进行从上到下竖列排版,我们知道CSS样式中有一样式可以让其竖列排版,但所有浏览器不全兼容,逼不得已放弃. ...

  7. ​? super T ? extends T

    ​? super T ?保存的是  T类型或者T类型的父类 ​ ? extends T ?保存的是  T类型或者T类型的子类

  8. 【HDOJ】4587 TWO NODES

    Tarjan解无向图的割点和桥,参考白书. /* 4587 */ #include <iostream> #include <vector> #include <algo ...

  9. (转载)prepare函数的学习,我要学习php第二天

    (转载)http://www.boyuan78.com/htm/company/2012_1030_60.html prepare函数的学习,我要学习php第二天 $mysqli = new mysq ...

  10. (转载)PHP isset()函数作用

    (转载)http://www.cnblogs.com/neve/archive/2011/03/21/1990165.html isset函数是检测变量是否设置. 格式:bool isset ( mi ...