宣言android.graphics.Bitmap.createScaledBitmap是
public static Bitmap createScaledBitmap
(Bitmap src, int dstWidth, int dstHeight, boolean filter)
Run Code Online (Sandbox Code Playgroud)
但是,文档没有解释任何参数.所有这些都非常明显,除了boolean filter.有谁知道它的作用?
我正在尝试制作一个视图,其背景不仅透明,而且还具有模糊效果.这样,下面的视图似乎没有焦点.按住电源按钮,我希望它看起来像屏幕一样.有任何想法吗?
我有一个我已经透明的Linearlayout,现在我正在寻找一种方法来赋予它一个模糊效果,所以它下面的东西变得模糊.就像Windows 7 Aero外观一样(见截图).
我知道你可以做这样的模糊效果:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Run Code Online (Sandbox Code Playgroud)
但这仅适用于在出现对话框时模糊背景.
我一直在谷歌搜索近一个小时,我找不到任何东西.有没有人对如何做到这一点有任何建议?
谢谢

过去三天我一直在寻找内置的硬件加速方式,用android来模拟位图.我偶然发现了某些解决方法,比如缩小位图并再次缩放,但这种方法产生的质量低,不适合我的图像识别要求.我还读到使用着色器或JNI实现卷积是一个很好的方法,但我不能相信Android框架中没有内置的解决方案用于这个非常常见的目的.目前我最终在Java中使用自编写的卷积实现,但它的速度非常慢.我的问题是:
正如我们从API 14中了解到的那样,下面的模糊已被弃用
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Run Code Online (Sandbox Code Playgroud)
是否有任何替代方法可以使Dialog背后的屏幕模糊我尝试了FAST模糊
基本上
在一个活动中,我有一个ListView.当我选择一个项目时,透明活动将作为一个小框打开.出现此框时,您仍然可以查看以前的活动屏幕,
我想弄清楚的是如何模糊前一个屏幕,就像这里链接的图像一样(忽略用户界面,只看模糊的草地区域).
这怎么可能?
谢谢你的任何建议.
我有一个imageview,我以编程方式设置Image Resources:
int resourceId = getResources().getIdentifier("imagename", "drawable", "mypackage");
imgLock.setImageResource(resourceId);
Run Code Online (Sandbox Code Playgroud)
有没有简单的方法来显示我的ImageView模糊图像?
我对RenderScript ScriptIntrinsic Blur有一些问题 - 在某些设备上它不会模糊整个图像.我缩小输入图像的尺寸并确保宽度是4的倍数(因为它是由Roman Nurik建议的:https://plus.google.com/+RomanNurik/posts/TLkVQC3M6jW)
@SuppressLint("NewApi")
private Bitmap blurRenderScript(Bitmap smallBitmap) {
Bitmap output = Bitmap.createBitmap(smallBitmap.getWidth(), smallBitmap.getHeight(), smallBitmap.getConfig());
RenderScript rs = RenderScript.create(getContext());
ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation inAlloc = Allocation.createFromBitmap(rs, smallBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE);
Allocation outAlloc = Allocation.createFromBitmap(rs, output);
script.setRadius(BLUR_RADIUS);
script.setInput(inAlloc);
script.forEach(outAlloc);
outAlloc.copyTo(output);
rs.destroy();
MutableBitmap.delete(smallBitmap);
return output;
}
Run Code Online (Sandbox Code Playgroud)
它正在开发Nexus 4:


但在Galaxy S4上,右侧有透明边缘:


我希望你能看出我的意思 - 如果你用gimp打开图片,或者你可以更好地看到它.它不依赖于图片大小.我也尝试了越来越大的图像,结果总是一样的.例如,它也发生在Nexus 7 2012上.此外,透明工件有时位于bottem或左边缘.在此先感谢您的帮助!
Nexus 4:4.4.2/Build Number KOT49H Galaxy S4:4.2.2/Build Number JDQ39.I9505XXUDMGG
我喜欢iOS 7用于他们的Notification和Music popover 的风格,如下所示.

所以,我尝试在Android中实现这个功能.在做了一些搜索后,我实现了如何做到这一点.我试过的是跟随.
1)首先,我使用View的根参考,并使用getDrawingCache()View的功能拍摄它.
linearLayout.buildDrawingCache();
SoftReference<Bitmap> bitmap = new SoftReference<Bitmap>(
Bitmap.createBitmap(linearLayout.getDrawingCache()));
linearLayout.destroyDrawingCache();
Run Code Online (Sandbox Code Playgroud)
2)我取相对于其父项的位置,并根据要求剪切图像.
SoftReference<Bitmap> temp = new SoftReference<Bitmap>(
Bitmap.createBitmap(bitmap.get(), 0,
(parentHeight - childHeight), childWidth, childHeight));
Run Code Online (Sandbox Code Playgroud)
3)我用一些算法使位图图像模糊.(我使用Fast Bitmap Blur For Android SDK fastBlur效果)
4)在叠加视图中设置它.
imageView1.setImageBitmap(Utils.fastblur(temp.get(), 8));
Run Code Online (Sandbox Code Playgroud)
但我的问题是需要时间来拍摄然后给出模糊效果并切割图像然后我得到了最终结果.虽然iOS具有非常快速的模糊过程,例如当抽屉从底部进入时,它会立即模糊背后的屏幕.
有没有其他方法可以实现这一目标?因为使用我的场景,我不能每隔一秒拍摄一次屏幕,并且在抽屉的每一次移动中每秒都进行1到4次处理.
我试图使用RenderScript支持库中的ScriptIntrinsicBlur模糊图像.我正在使用gradle,我使用这种方法来使用RenderScript的支持库版本.
在我的Nexus 4上,一切正常并且速度非常快,但是当我在搭载Android 2.3.3的三星Galaxy S上试用它时,我得到的图片看起来像这样:

我正在使用Roman Nurik的提示将位图宽度设置为4的倍数,但我不认为这是我的问题的原因.我的模糊代码看起来与这篇文章完全一样.谢谢你的建议.
这是我的代码:
获取视图的位图并重新缩放位图:
public static Bitmap loadBitmapFromView(View v) {
v.setDrawingCacheEnabled(false);
v.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
v.setDrawingCacheEnabled(true);
Bitmap b = v.getDrawingCache();
return b;
}
public static Bitmap scaledBitmap(Bitmap dest, float scale) {
int scaledWidth = (int) (scale * dest.getWidth());
if (scaledWidth % 4 != 0) { //workaround for bug explained here https://plus.google.com/+RomanNurik/posts/TLkVQC3M6jW
scaledWidth = (scaledWidth / 4) * 4;
}
return Bitmap.createScaledBitmap(dest, scaledWidth, (int) (scale * dest.getHeight()), true);
}
Run Code Online (Sandbox Code Playgroud)
Renderscript代码:
Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true); …Run Code Online (Sandbox Code Playgroud) android ×10
blur ×3
java ×2
renderscript ×2
artifact ×1
background ×1
convolution ×1
ios ×1
scaling ×1
transparent ×1