这段代码来自苹果的WWDC 2011会议318-深入了解iOS性能,使用CoreGraphics从服务器托管的图像创建缩略图。
但它不起作用,文档也没有什么帮助。在iOS文档中,可以使用CGImageSource、CGImageSourceRef和CGImageSourceCreateThumbnailAtIndex。在Mac OS X v10.4或更高版本中可用。我该怎么做才能让它起作用?
编辑: 这些是我得到的编译错误: - 使用未声明的标识符'CGImageSourceRef' - 使用未声明的标识符'kCGImageSourceThumbnailMaxPixelSize' - 使用未声明的标识符'src' - 在C99中,隐式声明函数'CGImageSourceCreateThumbnailAtIndex'无效 - 在C99中,隐式声明函数'CGImageSourceRelease'无效 - 在C99中,隐式声明函数'CGImageSourceCreateWithURL'无效
CGImageSourceRef src = CGImageSourceCreateWithURL(url);
NSDictionary *options = (CFDictionaryRef)[NSDictionary
dictionaryWithObject:[NSNumber numberWithInt:1024
forKey:(id)kCGImageSourceThumbnailMaxPixelSize];
CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src,0,options);
UIImage *image = [UIImage imageWithCGImage:thumbnail];
CGImageRelease(thumbnail);
CGImageSourceRelease(src);
但它不起作用,文档也没有什么帮助。在iOS文档中,可以使用CGImageSource、CGImageSourceRef和CGImageSourceCreateThumbnailAtIndex。在Mac OS X v10.4或更高版本中可用。我该怎么做才能让它起作用?
编辑: 这些是我得到的编译错误: - 使用未声明的标识符'CGImageSourceRef' - 使用未声明的标识符'kCGImageSourceThumbnailMaxPixelSize' - 使用未声明的标识符'src' - 在C99中,隐式声明函数'CGImageSourceCreateThumbnailAtIndex'无效 - 在C99中,隐式声明函数'CGImageSourceRelease'无效 - 在C99中,隐式声明函数'CGImageSourceCreateWithURL'无效