Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: GNU General Public License 

import android.graphics.Bitmap;

import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;

import android.graphics.Shader.TileMode;

public class Main {
    static private Bitmap smallCoverPostProc(Bitmap smallBitmap) {
        try {
            Bitmap smallBitmapPostProc = Bitmap.createBitmap(smallBitmap.getWidth(), smallBitmap.getHeight(),
                    Bitmap.Config.RGB_565);
            Canvas canvas = new Canvas();
            canvas.setBitmap(smallBitmapPostProc);
            Paint paint = new Paint();
            paint.setAntiAlias(true);
            Bitmap bitmapToShade = Bitmap.createBitmap(smallBitmap, 2, 2, smallBitmap.getWidth() - 4,
                    smallBitmap.getHeight() - 4);
            BitmapShader bmShader = new BitmapShader(bitmapToShade, TileMode.CLAMP, TileMode.CLAMP);
            paint.setShader(bmShader);
            canvas.drawRoundRect(new RectF(2, 2, smallBitmap.getWidth() - 2, smallBitmap.getHeight() - 2), 4, 4,
                    paint);
            return smallBitmapPostProc;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}