画图片

来源:互联网 发布:db2链接数据库 编辑:程序博客网 时间:2024/03/28 20:56

`- (void)rotateTapped:(id)sender {
UIImage *currentImage = _imageView.image;
CGImageRef currentCGImage = currentImage.CGImage;

CGSize originalSize = currentImage.size;CGSize rotatedSize = CGSizeMake(originalSize.height, originalSize.width);CGContextRef context = CGBitmapContextCreate(NULL,                                             rotatedSize.width,                                             rotatedSize.height,                                             CGImageGetBitsPerComponent(currentCGImage),                                             CGImageGetBitsPerPixel(currentCGImage) * rotatedSize.width,                                             CGImageGetColorSpace(currentCGImage),                                             CGImageGetBitmapInfo(currentCGImage));CGContextTranslateCTM(context, rotatedSize.width, 0.0f);CGContextRotateCTM(context, M_PI_2);CGContextDrawImage(context, (CGRect){.origin=CGPointZero, .size=originalSize}, currentCGImage);CGImageRef newCGImage = CGBitmapContextCreateImage(context);UIImage *newImage = [UIImage imageWithCGImage:newCGImage];self.imageView.image = newImage;

}
`

0 0