2017-11-02 20 views
-3

画像のぼやけた画像を背景に設定したい。画像の表示領域が矩形のようになります。正方形の画像の場合、Backround画像はその画像を保持しませんアスペクト比。 どのようにして矩形領域の背景として二乗画像を設定できますか?画像のblured画像を背景に設定したい

私は

Bitmap outputBitmap = Bitmap.createScaledBitmap(image, image.getWidth(), image.getHeight(),true); 
    final RenderScript renderScript = RenderScript.create(MyApplication.getContext()); 
    Allocation tmpIn = Allocation.createFromBitmap(renderScript, image); 
    Allocation tmpOut = Allocation.createFromBitmap(renderScript, outputBitmap); 
    //Intrinsic Gausian blur filter 
    ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript)); 
    theIntrinsic.setRadius(BLUR_RADIUS); 
    theIntrinsic.setInput(tmpIn); 
    theIntrinsic.forEach(tmpOut); 
    tmpOut.copyTo(outputBitmap); 
    renderScript.destroy(); 

スクリーンショットがbelow.I与えられている以下のコードを使用しているぼやけた画像で背景を塗りつぶしたい screenshot

答えて

0

あなたはぼかし変換を使用してグライドを経由して、これを行うことができます。コードの下に

public static void setBlurImageToBackground(final Context context, final String path, final ImageView imageView) { 
    imageView.postDelayed(new Runnable() { 
     @Override 
     public void run() { 
      Glide.with(context).load(path) 
        .apply(bitmapTransform(new BlurTransformation(25))) 
        .into(imageView); 
     } 
    }, DELAY_DURATION); 
} 

注意してみてください:追加以下

compile 'com.github.bumptech.glide:glide:3.7.0' 
compile 'jp.wasabeef:glide-transformations:3.0.1' 
+0

は、それがエラーの原因と依存関係になっていない@Abdul Waheed – Nej

+0

を「あなたが目標としているビューのグライドにsettag()を呼び出してはいけません」あなたはグライドのエラーを設定する必要がありますあなたの画像を見るには –

+0

[1]:https://i.stack.imgur.com/CQEuo.pngこれが出力です。背景を記入してください。 @Abdul Waheed – Nej

関連する問題