1
我使用CIPixellate在ios6中對圖像進行像素化。它會產生更大的圖像。我怎樣才能保持原來的大小?CIPixellate輸出圖像大小不同
NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(capturedImageView.image, 1.0)];//[NSData dataWithData:UIImagePNGRepresentation(capturedImageView.image)];
beginImage = [CIImage imageWithData:imageData];
context = [CIContext contextWithOptions:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:kCIContextUseSoftwareRenderer]];
filter = [CIFilter filterWithName:@"CIPixellate" keysAndValues:kCIInputImageKey, beginImage, @"inputScale", [NSNumber numberWithFloat:14.0], nil];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:CGRectMake(0, 0, 320, 480)];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
//新圖像的尺寸更大,大部分裁剪: -/