Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.BitmapFactory;

public class Main {
    private static int computeSampleSize1(BitmapFactory.Options options, int targetW, int targetH) {

        //      int s = 2;
        //      while ((options.outWidth / s > targetW) || (options.outHeight / s > targetH)) {
        //         s *= 2;
        //      }
        //      return s;

        int yRatio = (int) Math.ceil(options.outHeight / targetH);
        int xRatio = (int) Math.ceil(options.outWidth / targetW);
        if (yRatio > 1 || xRatio > 1) {
            if (yRatio > xRatio) {
                return yRatio;
            } else {
                return xRatio;
            }
        }

        return 1;
    }
}