Chcę utworzyć miniaturę za pomocą CG. Tworzy miniatury.CGImage utworzyć miniaturę obrazu o pożądanym rozmiarze
Tutaj chcę mieć miniaturę o rozmiarze 1024 (ze współczynnikiem kształtu). Czy można uzyskać miniaturę o pożądanym rozmiarze bezpośrednio z CG?
W słowniku opcji mogę przekazać maksymalny rozmiar thumnail może zostać utworzony, ale czy istnieje sposób, aby mieć minimalny rozmiar dla tego samego ..?
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);
}