ios中图片的绘画和截图
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中图片的绘画和截图的更多相关文章
- IOS中图片拉伸技巧与方法总结(转载)
以下内容转载自:http://my.oschina.net/u/2340880/blog/403996 IOS中图片拉伸技巧与方法总结 一.了解几个图像拉伸的函数和方法 1.直接拉伸法 简单暴力,却是 ...
- 谈谈 iOS 中图片的解压缩
原文 对于大多数 iOS 应用来说,图片往往是最占用手机内存的资源之一,同时也是不可或缺的组成部分.将一张图片从磁盘中加载出来,并最终显示到屏幕上,中间其实经过了一系列复杂的处理过程,其中就包括了对图 ...
- 【转】谈谈 iOS 中图片的解压缩
转自:http://blog.leichunfeng.com/blog/2017/02/20/talking-about-the-decompression-of-the-image-in-ios/ ...
- IOS中图片加载的一些注意点
图片的加载: [UIImage imageNamed:@"home"] //加载 png图片 在ios中获取一张图片只需要写图片名即可 不需要写后缀 默认都是加载.png的图片 但 ...
- ios中图片拉伸用法
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCap ...
- iOS开发:iOS中图片与视频一次性多选 - v2m
一.使用系统的Assets Library Framework这个是用来访问Photos程序中的图片和视频的库.其中几个类解释如下 ALAsset ->包含一个图片或视频的各种信息 ALAsse ...
- iOS中图片动画的三种模式及基本的代码实现
-(void)play { //第一种图片动画模式 头尾方式 //头尾方式 [UIView beginAnimations:nil context:nil];//动画开始 [UIView setAni ...
- iOS中图片拉伸,类似Android中的点9图片
UIImage* img=[UIImage imageNamed:@"name.png"];//原图 UIEdgeInsets edge=UIEdgeInsetsMake(, , ...
- ios中图片旋转
@interface ViewController () { UIImageView *_imageview; BOOL flag; } @end @implementation ViewContro ...
随机推荐
- In Place Upgrade of CentOS 6 to CentOS 7
Note: This is not the most highly recommended method to move from CentOS 6 to CentOS 7 ... but it ca ...
- iOS:NAV+TABLE结合
功能:点击列表项,用列表字符串作为参数创建一个新视图,新视图默认可以有一个BACK按钮回到上一个视图 // // main.m // Hello // // Created by lishujun o ...
- Powerdesigner数据库建模--概念模型--ER图【转】
转自http://www.cnblogs.com/dekevin/archive/2012/07/18/2596745.html Powerdesigner数据库建模--概念模型--ER图 目标: ...
- [BZOJ 3669] [Noi2014] 魔法森林 【LCT】
题目链接:BZOJ - 3669 题目分析 如果确定了带 x 只精灵A,那么我们就是要找一条 1 到 n 的路径,满足只经过 Ai <= x 的边,而且要使经过的边中最大的 Bi 尽量小. 其实 ...
- php的ob实现页面静态化
php页面静态化的原理,用最少的代码解释页面静态化 如何应用:在插入或更新数据到数据库时,就执行一下代码是一种比较好的方法.比如:php执行add()方法时(就是插入数据时) //开启缓存 Ob_st ...
- leetcode面试准备:Multiply Strings
1 题目 Given two numbers represented as strings, return multiplication of the numbers as a string. Not ...
- 《Effective C++》内存管理
如果global new-hander没有成功配置,会抛出一个std::bad_alloc的exception. #include<iostream> #include<new> ...
- wcf客户端捕获异常
直接使用Exception进行捕获,然后在监视器中查看具体是哪一个异常 System.Exception {System.ServiceModel.Security.MessageSecurityEx ...
- bzoj2743
其实和bzoj1878类似只不过要求的是区间内数量多于1个的数字种数其实还是按照bzoj1878做只不过我们是把每一种数字下一个出现的位置+1,并把这个位置置为0 ..] of longint; ma ...
- -_-#【响应式】matchMedia
谈谈响应式Javascript <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...