2016-09-06 2 views

答えて

0

私は元の画像サイズを取得するには、°Fこれを使用して、まったく同じ問題を解決し、あなただけのサイズを渡す必要が== CGSizeMake(10000000000、10000000000)、このヘルプを願っています:)

+ (UIImage *)createThumbFromImageIO:(UIImage*)image maxPixelSize:(CGSize)size 
{ 
    NSData *imagedata = UIImageJPEGRepresentation(image, 1); 
    CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imagedata, NULL); 

    if (!imageSource) return nil; 

    CGSize imageSize = image.size; 

    imageSize = CGSizeMake(size.width,size.height); 

    CFDictionaryRef options = (__bridge CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys: 
                 (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform, 
                 (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent, 
                 (id)[NSNumber numberWithFloat:imageSize.height], (id)kCGImageSourceThumbnailMaxPixelSize, 
                 nil]; 

    CGImageRef imgRef = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options); 

    image = [UIImage imageWithCGImage:imgRef]; 

    CGImageRelease(imgRef); 

    CFRelease(imageSource); 
    return image; 
} 
関連する問題