androidandroid-layoutimage-processingscalrimgscalr

Android How to use Scalr 4.2 or 'java-image-scaling' for HQ thumbnails


I'm trying to create high quality thumbnails, have tried most-if-not-all methods with Android and not yet satisfied.

Here is a good post I found, in which I would like to try using Scalr or 'java-image-scaling' library for Android.

Here are Scalr and 'java-image-scaling'

Question: Can I use them in Android dev and How? (since I didn't see it mentions anywhere)


Solution

  • Its not possible to use Scalr with android because it uses java.awt.image.BufferedImage, which isn't part of the Android SDK (neither is the rest of java.awt).

    Android uses android.graphics.Bitmap, not BufferedImage. I've yet to find as good of a library for Android as Scalr, but the Bitmap class support scaling, rotations and other transformations pretty well, look at createBitmamp with the matrix parameter.

    For example, the following code flips a bitmap, then saves it in another bitmap

    Matrix mirrorMatrix = new Matrix();
    mirrorMatrix.preScale(-.5f, .5f);
    // Create a flipped sprite using the transform matrix and the original sprite
    flippedBitmap = Bitmap.createBitmap(orgBitmap, 0, 0, orgBitmap.getWidth(), orgBitmap.getHeight(),mirrorMatrix, true);