2012-05-14 42 views
0

我试图从ALAsset之前为iOS5创建宽高比缩略图(ALAssetDefaultRepresentation aspectRatioThumbnail直到ios5才实现)。我有下面的代码和它给我一个错误由于某些原因:尝试从图像I/O创建AspectRatio缩略图时出错

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 

任何人都知道这是怎么回事?

+2

我已经提出了一个关于如何从ALAsset生成一个答案:http://stackoverflow.com/questions/11765340/generating-custom-thumbnail-from-alassetrepresentation/13941431#13941431 –

回答

1

的问题是,你是通过打造“src”, 请检查是否url是有效的,并在此URL存在一些图像url

+0

我觉得我正在检索的网址不是用于图片,而是用于资源本身。任何想法如何获得图像的网址? –