获取图片中间的正方形
+(UIImage*)smallImage:(UIImage*)bigImg
{
CGSize imgsize = bigImg.size;
NSInteger w = imgsize.width>imgsize.height?imgsize.height:imgsize.width;
CGRect rect;
if(imgsize.width>imgsize.height)
{
rect = CGRectMake((imgsize.width-imgsize.height)/2, 0, w, w);
}
else {
rect = CGRectMake(0, (imgsize.height-imgsize.width)/2, w, w);
}
CGImageRef imageRef =
CGImageCreateWithImageIn
}
按照等比例缩放后的图片
+(UIImage*)CompressImage:(UIImage*)bigImg
{
CGSize imgsize = bigImg.size;
CGRect rect = CGRectMake(0, 0, imgsize.width, imgsize.height);
CGImageRef imageRef =
CGImageCreateWithImageIn
int h = croppedImage.size.height;
int w = croppedImage.size.width;
float b = (float)kAppIconWeidth/w < (float)kAppIconHeight/h ? (float)kAppIconWeidth/w : (float)kAppIconHeight/h;
UIImage *img = nil;
CGSize itemSize = CGSizeMake(b*w, b*h);
UIGraphicsBeginImageCont
CGRect imageRect = CGRectMake(0, 0, b*w, b*h);
[croppedImage drawInRect:imageRect];
img =
UIGraphicsGetImageFromCu
UIGraphicsEndImageContex
return img;
}
类别:Uiimage 查看评论