目前在我正在开发的Android应用程序中,我正在循环遍历图像的像素以使其模糊.这在640x480图像上大约需要30秒.
在Android Market中浏览应用程序时,我遇到了一个包含模糊功能的应用程序,并且它们的模糊非常快(例如5秒),因此它们必须使用不同的模糊方法.
除了循环像素之外,任何人都知道更快的方法吗?
我希望对话框在其下具有模糊的屏幕,因此我对活动进行“截屏”,对其进行模糊处理并将其设置为BitmapDrawable作为对话框窗口的背景。奇怪的是,即使调用setCanceledOnTouchOutside(true),对话框也不再位于屏幕中央,并且触摸外部对话框也不会关闭对话框。
问题是:为什么这不起作用?如何分别创建背景模糊的对话框?
public class BlurDialog extends DialogFragment {
public BlurDialog() {
}
public static BlurDialog newInstance() {
return new BlurDialog();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
.setTitle("Title")
.setMessage("Message")
.setPositiveButton("OK", null)
.setNegativeButton("Cancel", null)
.create();
alertDialog.setCanceledOnTouchOutside(true);
View view = getActivity().getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
Bitmap b1 = view.getDrawingCache();
Rect frame = new Rect();
getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
final int width = getActivity().getWindow().getDecorView().getWidth();
final int height = getActivity().getWindow().getDecorView().getHeight();
Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height-statusBarHeight);
//define this …Run Code Online (Sandbox Code Playgroud)