此代碼來自Apple的WWDC 2011 Session 318 - 深度iOS性能,並使用CoreGraphics從服務器託管的圖像創建縮略圖。CoreGraphics圖片大小調整
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'
- 函數的隱式聲明'CGImageSourceCreateThumbn ailAtIndex」是C99無效
- 的功能隱式聲明 'CGImageSourceRelease' 是C99無效
- 的功能隱式聲明 'CGImageSourceCreateWithURL' 是C99
的iOS文件實際上是[這裏](http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGImageSource/Reference/reference.html)和在iOS 4.0及更高版本中聲明可用性。嘗試說明問題的確切來源。你甚至會得到一個有效的'src'。附:在apple.developer論壇之外討論WWDC會話並不是一個好主意 - 因爲所有引用的函數都不在NDA之下,所以我想你是o.k. :) –
啊yep沒有看到iOS 4 +進一步下降。編輯錯誤。此外,這是從去年的WWDC,這是好的沒有? – daidai
我想應該沒問題,雖然我記得在某個地方唱disclamer。 –