One of the most popular effects in mobile today is the “blur”. Although the blur effect is most commonly associated with iOS, several notable apps such as Etsy’s Android app use this technique.
The Ti.Blur module now provides Android support so that you can use this popular effect in both your Android and iOS Titanium apps.
The initial release of Ti.Blur for Android provides two APIs make applying a Box Blur easy. The first APIs is an extended Ti.UI.View object called, BasicBlurView. This view works similar to a Ti.UI.ImageView and applies the blur effect to the image or screenshot provide. The second API is a called applyBlurTo and allows you to directly apply the Box Blur effect to an image.
The following shows them module’s example app in action.
BasicBlurView on Android
The basicBlurView is a new view object within the Ti.Blur module. This view object applies a Box Blur to any image provided to it’s image property. The blurRadius property is used to determine the level of blur that is applied.
This view would typically be used to blur an image, such as background image that you already have available in your app, or by taking a capture of the device’s current screen and providing it to the basicBlurView.
The basicBlurView is also cross-platform providing support for both Android and iOS.
var mod = require('bencoding.blur'); var win = Ti.UI.createWindow({ backgroundColor:'white', title:"Image Blur Demo" }); var vwTest = mod.createBasicBlurView({ width:Ti.UI.FILL, height:Ti.UI.FILL, blurRadius:10, image: 'your-image-here.png' }); win.add(vwTest); win.open();
Blurring an image without a View object
The Ti.Blur module allows you to blur an image or blob directly without the use of a View object. This is helpful if you want to cache the image for later, or use one of Titanium’s other built in UI objects.
The following code snippet is from the example app demonstrating how to apply a blur to an existing image packaged in your app.
var mod = require('bencoding.blur'); var win = Ti.UI.createWindow({ backgroundColor:'white', title:"Image Blur Demo" }); var imgblurredImage = mod.applyBlurTo({ image:'42553_m.jpg', blurRadius:10 }); var vwTest = Ti.UI.createImageView({ width:Ti.UI.FILL, height:Ti.UI.FILL, image:imgblurredImage }); win.add(vwTest); win.open();
Getting Started
Get started using Ti.Blur on either iOS or Android using the below links:
Source:
Modules:
Documentation:
Examples: