我正在使用 CIPixellate 在 ios6 中对图像进行像素化。它会产生更大的图像。我怎样才能保持原来的大小?
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];
// 新图像尺寸更大,大部分被裁剪:-/