Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

import android.view.View;

public class Main {
    public static float sScaleFactor = 8;

    private static Bitmap getResizeBitmap(View view, Bitmap bitmap) {
        Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasuredWidth() / sScaleFactor),
                (int) (view.getMeasuredHeight() / sScaleFactor), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(overlay);
        canvas.translate(-view.getLeft() / sScaleFactor, -view.getTop() / sScaleFactor);
        canvas.scale(1 / sScaleFactor, 1 / sScaleFactor);
        Paint paint = new Paint();
        paint.setFlags(Paint.FILTER_BITMAP_FLAG);
        canvas.drawBitmap(bitmap, 0, 0, paint);
        return overlay;
    }
}