当前位置: 首页 > 软件库 > 手机/移动开发 > >

blurkit-android

授权协议 MIT License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 江凯风
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

What Is BlurKit?

BlurKit is an extraordinarily easy to use and performant utility to render real time blur effects in Android.

Perfomance

BlurKit is faster than other blurring libraries due to a number of bitmap retrieval and drawing optimizations. We've been logging benchmarks for the basic high-intensity tasks for a 300dp x 100dp BlurView:

Task BlurKit time Avg. time without BlurKit
Retrieve source bitmap 1-2 ms 8-25 ms
Blur and draw to BlurView 1-2 ms 10-50ms

This results in an average work/frame time of 2-4ms, which will be a seamless experience for most users and apps.

Setup

Add BlurKit to the dependencies block of the app level build.gradle:

dependencies {
    implementation 'io.alterac.blurkit:blurkit:1.1.0'
}

Usage

BlurLayout

Add a BlurLayout to your XML layout just like any other view.

<io.alterac.blurkit.BlurLayout
    android:id="@+id/blurLayout"
    android:layout_width="150dp"
    android:layout_height="150dp"/>

In the Main_Activity.java you need to override the onStart() and onStop() methods to include the BlurLayout functionality.

BlurLayout blurLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    blurLayout = findViewById(R.id.blurLayout);
}

@Override
protected void onStart() {
    super.onStart();
    blurLayout.startBlur();
}

@Override
protected void onStop() {
    blurLayout.pauseBlur();
    super.onStop();
}

The layout background will continuously blur the content behind it. If you know your background content will be somewhat static, you can set the layout fps to 0. At any time you can re-blur the background content by calling invalidate() on the BlurLayout.

<io.alterac.blurkit.BlurLayout
    android:id="@+id/blurLayout"
    android:layout_width="150dp"
    android:layout_height="150dp"
    blurkit:blk_fps="0" />

Other attributes you can configure are the blur radius and the downscale factor. Getting these to work together well can take some experimentation. The downscale factor is a performance optimization; the bitmap for the background content will be downsized by this factor before being drawn and blurred.

<io.alterac.blurkit.BlurLayout
    android:id="@+id/blurLayout"
    android:layout_width="150dp"
    android:layout_height="150dp"
    blurkit:blk_blurRadius="12"
    blurkit:blk_downscaleFactor="0.12"
    blurkit:blk_fps="60" />

Creating BlurKit Outside Of A Layout

You can use the BlurKit class which has a few useful blurring utilities. Before using this class outside of a BlurLayout, you need to initialize BlurKit.

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        BlurKit.init(this);
    }
}

You can blur a View, or a Bitmap directly.

// View
BlurKit.getInstance().blur(View src, int radius);

// Bitmap
BlurKit.getInstance().blur(Bitmap src, int radius);

You can also fastBlur a View. This optimizes the view blurring process by allocating a downsized bitmap and using a Matrix with the bitmaps Canvas to prescale the drawing of the view to the bitmap.

BlurKit.getInstance().fastBlur(View src, int radius, float downscaleFactor);

Upcoming Features

  • SurfaceView support
  • Support for use outside of an Activity (dialogs, etc.)
  • Enhance retrieval of background content to only include views drawn behind the BlurLayout.

License

BlurKit is MIT licensed.


Blurkit is a sister project of CameraKit and maintained by the CameraKit team.

  •  本文已授权「玉刚说」微信公众号独家发布 毛玻璃效果实际上是对原图片的严重劣化,突出朦胧感,一般都是通过图片的缩放+模糊算法来实现,从性能角度考虑,模糊半径不能大于25,所以要更高的模糊效果则需要进行缩放。具体实现方案有以下几种。 Java实现,一般都是采用Stack模糊算法 RenderScript实现 Native实现 OpenCV或者OpenGL实现,由于其复杂度,本文暂不讨论该方案 关于模

  • 结合许多网上查到的资料书写一下,留自己一份资料。 许多并没有用过,下面的仅为个人的一些建议 1、图片加载,缓存,处理 框架名称    功能描述 Android Universal Image Loader     一个强大的加载,缓存,展示图片的库,已过时    不建议使用 Picasso     一个强大的图片下载与缓存的库                                    

  • 转载自:https://blog.csdn.net/weixin_37730482/article/details/80276864 分类 详细 框架名称 简介 Star 数 最近 更新 UI 刷新 SmartRefreshLayout Android 智能下拉刷新框架 7.7k 1天 UI 刷新 Android-PullToRefresh 比较早的一款下拉刷新框架 8.5k 4年 UI 刷新 a

 相关资料
  • 问题内容: 我正在尝试从一个发送客户类的对象,Activity然后在另一个对象中显示它Activity。 客户类的代码: 我想将其对象从一个对象发送Activity到另一个对象,然后在另一个对象上显示数据Activity。 我该如何实现? 问题答案: 一种选择是让你的自定义类实现该接口,然后可以使用该方法的变体在意图中额外传递对象实例。 伪代码:

  • 问题内容: 我很难找到最简单的方法来针对给定的JSON模式字符串验证JSON字符串(作为参考,这是在Java中运行在Android应用程序中)。 理想情况下,我只想传入JSON字符串和JSON模式字符串,并且它返回关于是否通过验证的布尔值。通过搜索,我发现了以下两个有前途的库可以完成此任务: http://jsontools.berlios.de/ https://github.com/fge/j

  • 问题内容: 我想每隔5秒重复调用一次方法,每当我希望停止该方法的重复调用时,我可能会停止或重新启动该方法的重复调用。 这是一些我真正想要实现的示例代码。在这方面请帮助我,我将非常感谢您。 问题答案: 使用以下命令设置重复任务: 如果您想取消任务,只需调用这里就是您的对象 并且您还可以检查答案下方的评论,他们已经提供了有关此内容的简短信息。

  • 问题内容: 我有一个活动,该活动的TabHost包含一组TabSpec,每个TabSpec都有一个listview,其中包含要由该选项卡显示的项目。创建每个TabSpec时,我设置一个图标以显示在选项卡标题中。 TabSpec是通过以下方法创建的,该方法循环创建适当数量的选项卡: 有几个实例,我希望能够更改程序执行过程中每个选项卡中显示的图标。目前,我正在删除所有选项卡,并再次调用上述代码以重新创

  • 问题内容: 如何通过android app向终端发送命令并获取输出?例如,发送“ ls /”并获取输出以在GUI中将其打印出来? 问题答案: 您必须使用反射来调用android.os.Exec.createSubprocess():

  • 问题内容: 我的应用程序显示了许多自定义对话框,例如“是/否”或“接受/取消决定”,并且在编写代码时,我意识到遵循相同的模式重复了太多代码。 我想建立一个通用类,但我不知道该怎么做,或更确切地说,我不知道该怎么做(接口,抽象类,继承,静态类等)。 这是我目前的课程: } 这就是我需要使用此类时要做的事情: 我敢肯定它是可改进的,但是您怎么能做到呢? 谢谢 问题答案: 首先创建一个Base 来保持的