【发布时间】:2010-12-18 04:42:24
【问题描述】:
我想使用 CG 创建缩略图。它创建缩略图。
这里我想要尺寸为 1024(纵横比)的缩略图。是否可以直接从 CG 中获得所需尺寸的缩略图?
在选项字典中,我可以通过可以创建缩略图的最大大小,但是有没有办法让最小大小相同..?
NSURL * url = [NSURL fileURLWithPath:inPath];
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
CGImageRef image=nil;
if (source)
{
NSDictionary* thumbOpts = [NSDictionary dictionaryWithObjectsAndKeys:
(id) kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform,
(id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent,
[NSNumber numberWithInt:2048], kCGImageSourceThumbnailMaxPixelSize,
nil];
image = CGImageSourceCreateThumbnailAtIndex(source, 0, (CFDictionaryRef)thumbOpts);
NSLog(@"image width = %d %d", CGImageGetWidth(image), CGImageGetHeight(image));
CFRelease(source);
}
【问题讨论】:
标签: size core-graphics thumbnails