モザイク
モザイク処理。なんだかドキドキします。
こでは全体を処理しているけど、対象がピックアップできたら該当部分だけモザイク処理をする事もできそう(目だけモザイクが入るとか)。
private Bitmap effectPixelization( Bitmap bitmap ){ if( bitmap == null ){ bitmap = BitmapFactory.decodeResource( getResources( ), R.drawable.original ).copy( Bitmap.Config.ARGB_8888, true ); } if( bitmap == null ){ return bitmap; } if( bitmap.isMutable( ) != true ){ bitmap = bitmap.copy( Bitmap.Config.ARGB_8888, true ); } int height = bitmap.getHeight( ); int width = bitmap.getWidth( ); int[] pixels = new int[( width * height )]; bitmap.getPixels( pixels, 0, width, 0, 0, width, height ); int i, j, ii, jj; int size = 10; for( i = 0; i < width; i += size ){ for( j = 0; j < height; j += size ){ int r, rr, g, gg , b, bb, counts; r = rr = g = gg = b = bb = counts = 0; for( ii = 0; ii < size; ++ii ){ for( jj = 0; jj < size; ++jj ){ if( ( i + ii ) < 0 || width <= ( i + ii ) || ( j + jj ) < 0 || height <= ( j + jj ) ){ continue; } int bitmapColor = pixels[( ( i + ii ) + ( j + jj ) * width )]; rr = Color.red( bitmapColor ); gg = Color.green( bitmapColor ); bb = Color.blue( bitmapColor ); r += rr; g += gg; b += bb; counts++; } } rr = r / counts; gg = g / counts; bb = b / counts; for( ii = 0; ii < size; ++ii ){ for( jj = 0; jj < size; ++jj ){ if( ( i + ii ) < 0 || width <= ( i + ii ) || ( j + jj ) < 0 || height <= ( j + jj ) ){ continue; } pixels[( ( i + ii ) + ( j + jj ) * width )] = Color.rgb( rr, gg, bb ); } } } } bitmap.setPixels( pixels, 0, width, 0, 0, width, height ); return bitmap; }