我試圖在圖像視圖中顯示的圖像上創建模糊的效果。我遇到過一個例子,它將圖像縮小到位圖中,然後重新放大(我認爲是雙線性濾波),到目前爲止圖像質量非常差。我正試圖獲得一個很好的光滑模糊。我目前使用的代碼是:無法在android中的imageview上創建位圖模糊效果
originalImage = BitmapFactory.decodeResource(getResources(),
mImageIds[coverFlow.getSelectedItemPosition()]);
xPos = originalImage.getWidth()/2;
zoomedImage = Bitmap.createBitmap(originalImage, xPos/2, yPos, width,
height);
int upWidth = (int) (width * 3.5); //width is 450 >> upWidth is 1575
int upHeight = (int) (height * 3.5); //height is 700 >> upHeight is 2450
int downWidth = (int) ((width * 1.75)*0.06); //width is 450 >> downWidth is 787.5
int downHeight = (int) ((height * 1.75)*0.06); //height is 700 >> downHeight is 1225
Bitmap ScaledUp = Bitmap.createScaledBitmap(zoomedImage, upWidth,
upHeight, true);
Bitmap BlurredImage = Bitmap.createScaledBitmap(ScaledUp, downWidth,
downHeight, true);
background.startAnimation(myFadeInAnimation);
background.setImageBitmap(BlurredImage);
background.setFocusable(true);
有人可以解釋發生了什麼問題嗎?我似乎無法得到平滑的模糊,它總是像素化。
你讀過這篇文章http://graphics-geek.blogspot.ru/2011/01/video-reflections-on-android.html? –
我剛剛看了一下它的好處,但我試圖讓它變得模糊,並且似乎使它更透明。 –
是的,但生成的圖像也是模糊的。看看'blurryBitmap'是如何創建然後模糊的 –