截取UIImage大小(可以用于制作缩略图)
来源:互联网 发布:条码采集器软件 编辑:程序博客网 时间:2024/06/04 20:08
+(UIImage *)scaleImage:(UIImage *)image toScale:(CGSize)reSize
{
float drawW = 0.0;
float drawH = 0.0;
CGSize size_new = image.size;
NSLog(@"%f",size_new.width);
NSLog(@"%f",reSize.width);
NSLog(@"%f",size_new.height);
NSLog(@"%f",reSize.height);
NSLog(@"------------------------------------");
if (size_new.width >= reSize.width) {
drawW = (size_new.width - reSize.width)/2.0;
}
if (size_new.height >= reSize.height) {
drawH = (size_new.height - reSize.height)/2.0;
}
//截取截取大小为需要显示的大小。取图片中间位置截取
CGRect myImageRect = CGRectMake(drawW, drawH, reSize.width, reSize.height);
UIImage* bigImage= image;
image =nil;
CGImageRef imageRef = bigImage.CGImage;
CGImageRef subImageRef = CGImageCreateWithImageInRect(imageRef, myImageRect);
UIGraphicsBeginImageContext(reSize);
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextDrawImage(context, myImageRect, subImageRef);
UIImage* smallImage = [UIImageimageWithCGImage:subImageRef];
UIGraphicsEndImageContext();
return smallImage;
}
- 截取UIImage大小(可以用于制作缩略图)
- 截取UIImage指定大小区域
- UIImage截图 截取指定大小图片
- 如何截取UIImage指定大小区域
- UIImage处理方法(缩放、自定义大小)
- UIView截取图片UIimage
- UIImage,UIImageView,截取圆形
- 缩略图制作
- 制作缩略图
- iphone UIImage 如何生成缩略图
- 生成缩略图的UIImage分类
- 可以用于游戏视频制作的人体运动捕捉
- 4412制作可以用于系统引导的TF卡
- 改DEDE5.3,的默认截取缩略图的大小,在那里改?
- C# 截取缩略图
- ios截取视频缩略图
- 截取视频缩略图
- iOS 截取视频缩略图
- FNV1、FNVS等发生abap dump
- android 备忘录4
- 精通maven实践
- linux之awk用法
- 导入excel错误:外部表不是预期的格式 解决方案
- 截取UIImage大小(可以用于制作缩略图)
- WebsenseURL 分类及应用识别类别信息
- click触发raisevent事件
- hdu 1134 game of connections(Catalan Number)
- 数据库使用拾遗
- 2013我不后悔,2014我们一起努力!
- Java构造二叉树以及三种递归遍历
- 锁和中断的交互
- Qt 正则表达式匹配 时分秒 00:00:00