BlurKit


Source link: https://github.com/wonderkiln/blurkit-android

BlurKit is an extraordinarily easy to use utility to get live blurring just like on iOS. Built by Dylan McIntyre.

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 your dependencies block:

compile 'com.wonderkiln:blurkit:1.0.0'

You also need to add RenderScript to your app module. Add these lines to the defaultConfig block of your build.gradle.

renderscriptTargetApi 24 renderscriptSupportModeEnabled true

Usage

BlurLayout

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

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

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:text="BlurKit!"

android:textColor="@android:color/white" />  </com.wonderkiln.blurkit.BlurLayout>

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.

<com.wonderkiln.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
  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.

<com.wonderkiln.blurkit.BlurLayout xmlns:blurkit="http://schemas.android.com/apk/res-auto"
  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" />

Other

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);

Proguard

If you use Proguard, add the following to your proguard-rules.pro:

-keep class com.wonderkiln.blurkit.** {
 *; 
}
  -dontwarn android.support.v8.renderscript.* -keepclassmembers class android.support.v8.renderscript.RenderScript {

native *** rsn*(...);

native *** n*(...);
 
}
 

To Do (incoming!)

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

Credits

Dylan McIntyre

License

BlurKit-Android is MIT licensed.

Resources

YouTubeHelper allows to fetch information from YouTube. You can get info about videos, users, comments, etc.

Android library with some Widgets and handy pieces of code I have developed.

Library contains:

  • Horizontal list.
  • Horizontal list with support for item removal.
  • Horizontal list with endless repeating of items.
  • CoverFlow widget derived from endless horizontal list.
  • ContentBand widget which allows for specify finer positioning of views inside scroll-able band using coordinates

Android CoverFlow widget with demo. Forked from ma-components.

DSAvataImageView is a subclass of ImageView to create a circle avatar image view with user name initial image view.

This library is used for converting Bitmap or Drawable images to Round or Circular Shape.

The Google APIs Client Library for Java is a flexible, efficient, and powerful Java client library for accessing any HTTP-based API on the web, not just Google APIs.

The library has the following features:

  • A powerful OAuth 2.0 library with a consistent interface.
  • Lightweight, efficient XML and JSON data models that support any data schema.
  • Support for protocol buffers.
  • A set of generated libraries for Google APIs.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes