すりガラス
すりガラス越しに見ているような画像に加工。
private Bitmap effectDiffuse( 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 radius = 10; Random random = new Random( ); for( int YY = 0; YY < width; ++YY ){ for( int XX = 0; XX < height; ++XX ){ int bitmapColor = pixels[( YY + XX * width )]; int rr = Color.red( bitmapColor ); int gg = Color.green( bitmapColor ); int bb = Color.blue( bitmapColor ); int Y = random.nextInt( radius * 2 ) - radius; int X = random.nextInt( radius * 2 ) - radius; if( ( Y + YY ) < 0 || width <= ( Y + YY ) || ( X + XX ) < 0 || height <= ( X + XX ) ){ continue; } pixels[( ( Y + YY ) + ( X + XX ) * width )] = Color.rgb( rr, gg, bb ); } } bitmap.setPixels( pixels, 0, width, 0, 0, width, height ); return bitmap; }