把图片切割的方法
2015-09-25 23:41
525 查看
- (UIImage *)clipImage: (UIImage *)image inRect: (CGRect) rect
{
//返回image中rect范围内的图片
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
UIImage *subImage = [UIImage imageWithCGImage:imageRef];
return subImage;
}
iv.image = [self clipImage:[UIImage imageNamed:@"king2"] inRect:CGRectMake(100*(i%3), 100*(i/3), 100, 100)];
DataStore *ds=[DataStore detectDataStore];
cell.textLabel.text=[ds.detectItems[indexPath.section][indexPath.row]myname];
cell.imageView.image=[ds.detectItems[indexPath.section][indexPath.row]img];
// cell.detailTextLabel.text=[ds.allItems[indexPath.section][indexPath.row]mydetailText];
CGSize itemSize = CGSizeMake(30, 30);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[cell.imageView.image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
{
//返回image中rect范围内的图片
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
UIImage *subImage = [UIImage imageWithCGImage:imageRef];
return subImage;
}
iv.image = [self clipImage:[UIImage imageNamed:@"king2"] inRect:CGRectMake(100*(i%3), 100*(i/3), 100, 100)];
DataStore *ds=[DataStore detectDataStore];
cell.textLabel.text=[ds.detectItems[indexPath.section][indexPath.row]myname];
cell.imageView.image=[ds.detectItems[indexPath.section][indexPath.row]img];
// cell.detailTextLabel.text=[ds.allItems[indexPath.section][indexPath.row]mydetailText];
CGSize itemSize = CGSizeMake(30, 30);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[cell.imageView.image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
相关文章推荐
- More Effective C++ 条款23 考虑使用其他程序库
- HDU 5445 Food Problem、UVa 10163 Storage Keepers、POJ 3260 The Fewest Coins(两次dp)
- C/C++ 中的次方运算
- java面试题十七 switch使用范围
- Android 实现微信,QQ的程序前后台切换:back键切换后台;点击通知栏恢复前台。
- 面向对象与面向过程
- UVA - 10129 Play on Words(欧拉回路+并查集)
- 安卓NDK编程使用STL库及注意事项
- 双边滤波
- ViewPager+Fragment的使用(页卡式切换下方带滚动条)
- java 之 集合
- (转)面向对象与面向过程
- Scala深入浅出进阶经典 第65讲:Scala中隐式转换内幕操作规则揭秘、最佳实践及其在Spark中的应用源码解析
- 360,京东,在线编程题
- Scala深入浅出进阶经典 第64讲:Scala中隐式对象代码实战详解
- the heapsort algorithm
- Struts2标签之set
- 360,京东,在线编程题
- Android应用开发系列(一):splash引导界面开发
- Unity3d 开发(四)代码创建预设