iphone 使用Core Graphics 剪贴图片

(void)cutOutImage:(UIImage *)cutedImage{

//设置要保存图片的大小

 CGSize subImageSize=cutLocation.textureRect.size;

//初始化一个矩形,这个矩形是设置剪贴以后图片得大小

 CGRect subImageRect=CGRectMake(KcutStartXKcutStartYKcutWidthKcutHeight);

CGImageRef imageRef=cutedImage.CGImage;

CGImageRef subImageRef=CGImageCreateWithImageInRect(imageRef, subImageRect);

UIGraphicsBeginImageContext(subImageSize);

CGContextRef context=UIGraphicsGetCurrentContext();

CGContextDrawImage(context, subImageRect, subImageRef);

//得到新得图片

UIImage *subImage=[UIImage imageWithCGImage:subImageRef];

UIGraphicsEndImageContext();

 

}

你可能感兴趣的:(graphics)