Tomo

Project Url: AllanHasegawa/Tomo
Introduction: Tomo is a collection of fast image processing effects for Android
More: Author   ReportBugs   
Tags:

Tomo is a collection of fast image processing effects for Android. Its main goal is to generate dynamic content for aesthetically pleasing apps.

The motivation behind this project can be read in this blog post.

Deprecation notice

Tomo is built on top of RenderScript (RS). Google is deprecating RS starting with Android 12. Given that, I don't recommend using Tomo on new projects.

Let me know if you would like to see Tomo for Vulkan and Compose though.

Showcase

In this demo app we showcase a cool adaptive background being generated using the content of the screen:

Using it

Add the snippet below in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Then, add the dependency to your module:

dependencies {
    compile 'com.github.AllanHasegawa:Tomo:x.y.z'
}

Latest release: Release

Initialize the library in your Application class:

class MyApp : Application {
    override fun onCreate() {
        Tomo.initialize(this)
        ...
    }
}

Now you're ready to either apply the effects over Bitmaps or ImageViews:

val myBitmap: Bitmap = ...
val bitmapProcessed = Tomo.applyAdaptiveBackgroundGenerator(myBitmap, darkTheme = true)

val myImageView: ImageView = ...
Tomo.applyAdaptiveBackgroundGenerator(myImageView, darkTheme = true)

Built-in effects

Adaptive Background Generator

Source Image Adaptive Background Generator
Dark Theme Light Theme

Custom effects

Tomo comes equipped with a list of image transformations that can be arranged in any order to build cool custom effects.

To transform a Bitmap, call Tomo::applyCustomTransformation():

val newBitmap = Tomo.applyCustomTransformation(oldBitmap) {
    // Scale to 1/10 of its size
    resize(
        newWidth = initialSize.width / 10,
        newHeight = initialSize.height / 10
    )

    // Blur it
    blur(radius = 25f)

    // Clamp the value (from HSV)
    valueClamp(
        lowValue = 0.05f,
        highValue = 0.3f,
        saturationMultiplier = 1.3f,
        saturationLowValue = 0f,
        saturationHighValue = 1f
    )

    // Apply a noise overlay
    grayNoise()
}

resize

resize, as the name implies, lets you resize the bitmap.

blur

blur applies a gaussian blur. It's maximum radius is 25f.

valueClamp

valueClamp clamps the value and the saturation of an image. It can also scale the saturation.

grayNoise

grayNoise applies a gray noise over the image.

rgbNoise

rgbNoise assigns a random, close, RGB color to each pixel.

License

Copyright 2019 Allan Yoshio Hasegawa

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Apps
About Me
GitHub: Trinea
Facebook: Dev Tools