A lightweight Kotlin library which converts images to PixelArt in Android.

Overview

PixelArtImageView

PixelArtImageView is a lightweight library used to convert standalone images into pixel art. The view extends ImageView behaviour and can therefore use any of it's properties. The library also implements callbacks allowing for you intercept events such as once an image has begun being converted to pixel art and upon completion in addition to providing some alternative configuration options.

Getting started

Download

For detailed instructions please check out the official Jitpack documentation.

Additionally you can download the project from the Github's release's page.

Or use Gradle:

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

dependencies {
    implementation 'com.github.Josh-Owen:PixelArtImageView:1.1.0'
}

Or Maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.Josh-Owen</groupId>
    <artifactId>PixelArtImageView</artifactId>
    <version>1.1.0</version>
</dependency>

Usage

The library makes use of a builder pattern and a simple usage of this library in Kotlin with:

ivPixelatedImage
    .load(R.drawable.yourdrawable)
    .setGridHeight(gridHeight)
    .setGridWidth(gridWidth)
    .onStart {  // Show your progress bar here  }
    .onFinished {  // Hide your progress bar here }
    .build()

Or alternatively it can be initialised in XML:

<com.joshowen.pixelart_imageview.PixelArtImageView
    android:id="@+id/pixelArtImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:gridWidth="88"
    app:gridHeight="88"
    app:enableAutomaticallyPixelate="true"
    app:srcCompat="@drawable/yourdrawable" />

Note: The XML approach will not show a progress bar and by default the image will show an empty ImageView unless you execute the following code in your activity or fragment.

binding.pixelArtImageView.build()

The library also implements a custom interface ImagePixelationListener which implements the following functions:

    fun onStart() (Optional)
    fun onFinished() (Mandatory)

This listener can be applied in the following way or alternatively implemented as an interface in your activity or view:

ivPixelatedImage
    .load(R.drawable.yourdrawable)
    .setGridHeight(gridHeight)
    .setGridWidth(gridWidth)
    .addPixelationListener(object : ImagePixelationListener {
    override fun onStart() {

    }

    override fun onFinished() {

    }
})
.build()

If you would like the original image to be displayed temporarily before being converted to a pixelated image the following properties can be applied:

In Kotlin in your builder:

.setOriginalImageHiddenByDefault(false)

Or in XML:

app:originalImageHiddenByDefault="false"

Samples

Samples: Canvas Width x 88 & Canvas Height x 88

Note: There are code samples demonstrating the usage of all of which in the demo project.

Thoughts

And that is all folks! I am open to suggestions in how to further improve this library to increase it's utility.

Be kind & help others. Cya!

You might also like...
A simple, lightweight, non-bloated redis client for kotlin and other JVM languages

rekt is a lightweight, non-bloated redis client, primarily written for the kotlin programming language, while also supporting other JVM-based languages, such as Java, Scala, and obviously way more.

A pragmatic lightweight dependency injection framework for Kotlin developers.
A pragmatic lightweight dependency injection framework for Kotlin developers.

A pragmatic lightweight dependency injection framework for Kotlin developers. Koin is a DSL, a light container and a pragmatic API

XCore is a Open-Source , simple and lightweight API & Template for Android Apps.

XCore XCore is a Open-Source , simple and lightweight API & Template for Android Apps. Support XCore is compatible with Android Studio & Sketchware Pr

A lightweight Trakt API.

This library is a lightweight Trakt API. It supports Swift, Kotlin, and JavaScript by setting up as a Kotlin Multiplatform project.

☁️ cloud.sh is a lightweight self-hosted cloud for your home lab.
☁️ cloud.sh is a lightweight self-hosted cloud for your home lab.

DISCLAIMER: cloud.sh is under development. We do not recommend you to use it in a production environment for now. The storage could be corrupted when

Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

A simple android library which helps you to create a curved bottom navigation

CurvedBottomNavigation A simple android library which helps you to create a curved bottom navigation DEMO Setup Update your module level build.gradle

Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers
Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers

Ktor Plugin Provides Ktor Server libs for building awesome Kotlin plugins which needs to provide builtin HTTP servers. Requires: https://github.com/Po

Spring Boot project scaffold written in Kotlin, which is based on the Official Guide.

Kotlin-Spring-Boot Spring Boot project scaffold written in Kotlin, which is based on the Official Guide. Development environment Windows choco install

Comments
Releases(1.1.0)
Owner
Josh Owen
Native Android Developer
Josh Owen
Kotools Assert is a lightweight assertions library for Kotlin

Kotools Assert is a lightweight assertions library for Kotlin

Kotools 1 Nov 3, 2022
Depenject - a lightweight, minimalistic dependency injection library for Kotlin/JVM.

depenject depenject is a lightweight, minimalistic dependency injection library for Kotlin/JVM. Our goal is similar to flavor's to simplify the usage

Patrick 1 Mar 22, 2022
An Android application to showcase dog images

DogApp An Android application to showcase dog images. The application allows users to see random dog images or random dog images by breed.The user can

Kieran 2 Nov 2, 2022
An Android app consuming Pixabay API to search and display list of images, built with MVVM pattern

Images An Android app consuming Pixabay API to search and display list of images, built with MVVM pattern as well as Architecture Components. Min Api

Ronnie Otieno 8 Sep 21, 2022
An Android app that scans images or human faces in real time and detects whether the mask is worn or not, with the ability to set an audible alert

Swift Mask Real time face mask detection Brief overview Swift Mask scans images or human faces in real time and detects whether the mask is worn or no

Giorgio Cantoni 4 Sep 22, 2022
A very simple Android app which shows you random memes with the help of meme-api which you can share with your friends!

Meme Share A very simple Android app which shows you random memes with the help of meme-api which you can share with your friends! Tech stack 100% wri

Stɑrry Shivɑm 8 Aug 10, 2022
A simple, lightweight and powerful field validation library for Android.

Convalida Convalida - (Italian for "validation") Convalida is a simple, lightweight and powerful field validation library for Android. Documentation G

Wellington Costa 203 Nov 18, 2022
A webapp which generates a simple Discord profile banner image in real-time which shows user's status and activity.

DiscordProfileBanner This tool generates a Discord profile banner image in realtime. I wrote it for use in my AniList profile. An example in action: H

Quanta 11 Oct 17, 2022
A lightweight library for requesting and consuming Activity Results using coroutines.

SuspendActivityResult A lightweight library for requesting and consuming Activity Results using coroutines, it's usage is as simple as: val uri = Acti

Hicham Boushaba 71 Dec 23, 2022
A lightweight tool for managing and building Kotlin projects.

kpm kpm (Kotlin Project Manager) is a lightweight tool for managing and building Kotlin projects. What is kpm? Essentially, kpm is going to be a light

Conor Byrne 5 Apr 23, 2022