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();

 

}

posted @ 2010-11-16 10:45  SsQq  阅读(237)  评论(0编辑  收藏  举报