這是我的壓縮碼如何壓縮和縮小NSImage?
NSBitmapImageRep* tmpRep = [[_image representations] objectAtIndex:0];
[tmpRep setPixelsWide:512];
[tmpRep setPixelsHigh:512];
[tmpRep setSize:NSMakeSize(SmallThumbnailWidth, SmallThumbnailHeight)];
NSDictionary* imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:0.3] forKey:NSImageCompressionFactor];
NSData* outputImageData = [tmpRep
representationUsingType:NSJPEGFileType properties:imageProps];
NSString* imageFilePath = [NSString stringWithFormat:@"%@/thumbnail.jpg",imagePath];
[outputImageData writeToFile:imageFilePath atomically:YES];
原始圖像尺寸是960 * 960.I想將原始圖像壓縮成512 * 512.But輸出圖像的尺寸爲960×960,當我在取景器檢查和原來相比的位置大小真的被壓縮了。任何人都可以告訴我爲什麼?謝謝
真棒,只是需要這個,'NSImage'是如此與'UIImage'不同,這爲我節省了一小時的研究時間! – 2013-09-29 12:01:08
嗨@ H2CO3:你跑到95K。我在過去6個月的項目中非常忙碌......因此無法給出單個答案:( – 2013-09-29 12:20:26