Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
src/main
README.md
build.gradle
proguard-rules.pro

README.md

Alfonz - Graphics Module

Utilities for working with bitmaps and drawables.

How to use bitmap utilities

BitmapBlur utility converts bitmap to blurred bitmap.

Bitmap originalBitmap = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.photo);
Bitmap blurredBitmap = BitmapBlur.getBlurredBitmap(getContext(), originalBitmap);
originalBitmap.recycle();
imageView.setImageBitmap(blurredBitmap);

BitmapReflection utility makes reflection effect.

Bitmap originalBitmap = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.photo);
Bitmap reflectedBitmap = BitmapReflection.getReflectedBitmap(originalBitmap, 0);
originalBitmap.recycle();
imageView.setImageBitmap(reflectedBitmap);

BitmapScaler utility is for resizing bitmaps. There are more variants for scaling.

Bitmap originalBitmap = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.photo);
Bitmap scaledBitmap = BitmapScaler.scaleToFill(originalBitmap, 512, 512);
originalBitmap.recycle();
imageView.setImageBitmap(scaledBitmap);

How to use drawables

CircularDrawable and RoundedDrawable are extended Drawables with circular/rounded shape.

CircularDrawable drawable = new CircularDrawable(bitmap);
imageView.setImageDrawable(drawable);
RoundedDrawable drawable = new RoundedDrawable(bitmap, radius);
imageView.setImageDrawable(drawable);

PlaceholderDrawable is a drawable showing initial letter of passed string on a colorful background.

PlaceholderDrawable drawable = new PlaceholderDrawable(text, "?", 50, true);
imageView.setImageDrawable(drawable);

Dependencies

  • Android Support Library

Samples and download

See the main README file.