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;

public class Main {
    public static Bitmap CompressBitmap(Bitmap image) {
        int width = image.getWidth();
        int height = image.getHeight();
        float scale = 500.0f / height;
        if (width > 500 || height > 500) {
            width = Math.round(width * scale);
            height = Math.round(height * scale);
        }
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        return scaledBitmap;
    }
}