1

ALAsset我正在尝试从iOS5 之前的版本创建纵横比缩略图(ALAssetDefaultRepresentation aspectRatioThumbnail直到 ios5 才实现)。我有以下代码,由于某种原因它给了我一个错误:

CGImageRef imref;
    NSURL* url = [self.photoAsset.defaultRepresentation url];
    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                       (id)kCFBooleanTrue, kCGImageSourceShouldAllowFloat,
                       (id)kCFBooleanTrue, kCGImageSourceCreateThumbnailWithTransform,
                       (id)kCFBooleanTrue, kCGImageSourceCreateThumbnailFromImageAlways,
                       [NSNumber numberWithInteger:1024], kCGImageSourceThumbnailMaxPixelSize, nil];
    CGImageSourceRef src = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
    imref = CGImageSourceCreateThumbnailAtIndex(src, 0, (CFDictionaryRef) dictionary);

具体来说,我得到:

ImageIO: <ERROR>  CGImageSourceCreateWithURL CFURLCreateDataAndPropertiesFromResource failed with error code -11.ImageIO: <ERROR>  CGImageSourceCreateThumbnailAtIndex image source parameter is nil

有谁知道发生了什么?

4

1 回答 1

1

问题url在于您要传递以创建“ src”,检查是否url有效并且此 url 中存在一些图像。

于 2012-05-14T20:58:18.680 回答