0

我有缩放 UIImage 的方法

- (UIImage*)croppedImageWithImage:(UIImage *)image zoom:(CGFloat)zoom
{
    CGFloat zoomReciprocal = 1.0f / zoom;

    CGPoint offset = CGPointMake(40, 40);
    CGRect croppedRect = CGRectMake(offset.x, offset.y, image.size.width * zoomReciprocal, image.size.height * zoomReciprocal);

    CGImageRef croppedImageRef = CGImageCreateWithImageInRect([image CGImage], croppedRect);

    UIImage* croppedImage = [[UIImage alloc] initWithCGImage:croppedImageRef scale:[image scale] orientation:[image imageOrientation]];

    CGImageRelease(croppedImageRef);

    return croppedImage;
}

缩放后如何保存图像宽度和高度?

4

2 回答 2

1

要保存缩放图像:

UIImageWriteToSavedPhotosAlbum(croppedImage, nil, nil, nil);

保存图像尺寸

CGSize imageSize = CGSizeMake(croppedImage.size.width, croppedImage.size.height);
于 2013-06-12T09:44:13.003 回答
0

如果要保存图像的宽度和高度,只需创建 CGSize 变量并保存如下

CGSize croppedSize = croppedImage.size
于 2013-06-12T09:49:30.683 回答