图片裁剪代码:

-(UIImage*)getSubImage:(UIImage*)p_w_picpath rect:(CGRect)rect

{

    CGRect newrect = CGRectMake(0, 0, rect.size.width*2, rect.size.height*2);

    CGImageRef subImageRef = CGImageCreateWithImageInRect(p_w_picpath.CGImage, newrect);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextDrawImage(context, newrect, subImageRef);

    UIImage* smallImage = [UIImage p_w_picpathWithCGImage:subImageRef];

    CGImageRelease(subImageRef);//手动释放

    UIGraphicsEndImageContext();

    

    return smallImage;

}