您的位置:首页 > 其它

iphone 使用Core Graphics 剪贴图片

2010-10-22 20:56 239 查看
(void)cutOutImage:(UIImage *)cutedImage{

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

CGSize subImageSize=cutLocation.textureRect.size;

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

CGRect subImageRect=CGRectMake(KcutStartX, KcutStartY, KcutWidth, KcutHeight);

CGImageRef imageRef=cutedImage.CGImage;

CGImageRef subImageRef=CGImageCreateWithImageInRect(imageRef, subImageRect);

UIGraphicsBeginImageContext(subImageSize);

CGContextRef context=UIGraphicsGetCurrentContext();

CGContextDrawImage(context, subImageRect, subImageRef);

//得到新得图片

UIImage *subImage=[UIImage imageWithCGImage:subImageRef];

UIGraphicsEndImageContext();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: