2015-08-03 39 views
0

我使用下面的代碼方的位圖是方形:模糊的平方位的Android

private static Bitmap squareBitMap(Bitmap givenBitmap) { 
     int dim = Math.max(givenBitmap.getWidth(), givenBitmap.getHeight()); 
     Bitmap resultBitmap= Bitmap.createBitmap(dim, dim, Config.ARGB_8888); 

     Canvas canvas = new Canvas(resultBitmap); 
     canvas.drawColor(Color.WHITE); 


     canvas.drawBitmap(givenBitmap, (dim - givenBitmap.getWidth())/2, (dim - givenBitmap.getHeight())/2, null); 

     return resultBitmap; 
    } 

code模糊的位圖。

有谷歌在許多應用程序播放模糊和方形位圖這樣的:

enter image description here

我怎樣才能做到這一點?

+0

可能重複HTTP ://stackoverflow.com/questions/2067955/fast-bitmap-blur-for-android-sdk) –

+0

檢查http://chiuki.github.io/android-shaders-filters/#/43。我沒有嘗試,但它可能是一個好點從開始;) – Gordak

回答

1

您可以使用下面庫模糊圖像使用下面的代碼,你必須創建方位

https://github.com/wasabeef/Blurry

if (srcBmp.getWidth() >= srcBmp.getHeight()){ 

    dstBmp = Bitmap.createBitmap(
    srcBmp, 
    srcBmp.getWidth()/2 - srcBmp.getHeight()/2, 
    0, 
    srcBmp.getHeight(), 
    srcBmp.getHeight() 
    ); 

}else{ 

    dstBmp = Bitmap.createBitmap(
    srcBmp, 
    0, 
    srcBmp.getHeight()/2 - srcBmp.getWidth()/2, 
    srcBmp.getWidth(), 
    srcBmp.getWidth() 
    ); 
} 
[快位圖模糊對於Android的SDK(的
+0

這個庫不會平方我的位圖... – Device

+0

首先,你必須在imageview中設置位圖和使用這個庫imageview可以blur.so你有編寫代碼來創建方形位圖 –

+0

我不想模糊整個圖像!看到我的問題的例子.. – Device