3

CIBloom を使用して 内のテキストをぼかしていますCGImageが、CIBloom フィルタによって画像がわずかに小さくなっているようです。

フィルター カーネルを大きくすると、効果が悪化します。私はこれを期待していましたが、それをオフにする方法、または各文字が元のサイズとまったく同じになるように画像のサイズを変更する式が必要です。ソース画像にわざと余白を残しています。

CIBloom フィルターの前:

a

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の結果が必要です。

4

2 に答える 2