这是我的压缩码如何压缩和缩小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