CIBloom を使用して 内のテキストをぼかしていますCGImage
が、CIBloom フィルタによって画像がわずかに小さくなっているようです。
フィルター カーネルを大きくすると、効果が悪化します。私はこれを期待していましたが、それをオフにする方法、または各文字が元のサイズとまったく同じになるように画像のサイズを変更する式が必要です。ソース画像にわざと余白を残しています。
CIBloom フィルターの前:
CIBloom フィルターの後:
フィルターをぼかすコード:
CGImageRef cgImageRef = CGBitmapContextCreateImage( tex->cgContext ) ;
CIImage *cii = [CIImage imageWithCGImage:cgImageRef] ;
CIFilter *filter = [CIFilter filterWithName:@"CIBloom"] ; //CIGaussianBlur
[filter setValue:cii forKey:kCIInputImageKey];
[filter setValue:[NSNumber numberWithFloat:1.1f] forKey:@"inputIntensity"];
// Large radius makes result EVEN SMALLER:
//[filter setValue:[NSNumber numberWithFloat:100.f] forKey:@"inputRadius"];
CIContext *ciContext = [CIContext contextWithOptions:nil];
CIImage *ciResult = [filter valueForKey:kCIOutputImageKey];
CGImageRef cgIRes = [ciContext createCGImage:ciResult fromRect:[ciResult extent]];
//Clear old tex
tex->clearBacking( 0, 0, 0, 1 ) ;
// Drop CIImage result into texture raw data
CGContextDrawImage( tex->cgContext, CGRectMake(0, 0, tex->w, tex->h), cgIRes ) ;
フィルターは気に入っていますが、ダウンサンプリングではなく、元の画像と同じサイズCIBloom
の結果が必要です。