【发布时间】:2012-05-14 20:25:40
【问题描述】:
我正在尝试从 iOS5 之前的 ALAsset 创建纵横比缩略图(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
有人知道怎么回事吗?
【问题讨论】:
-
我已经回答了这个关于如何从 ALAsset 生成 a 的问题:stackoverflow.com/questions/11765340/…
标签: iphone ios cocoa-touch core-graphics