get Bitmap Sample Size Auto Fit To Screen - Android Graphics

Android examples for Graphics:Bitmap Sample Size

Description

get Bitmap Sample Size Auto Fit To Screen

Demo Code


//package com.java2s;

public class Main {

    public static int getSampleSizeAutoFitToScreen(int vWidth, int vHeight,
            int bWidth, int bHeight) {
        if (vHeight == 0 || vWidth == 0) {
            return 1;
        }/*w  ww. j ava2 s . c  o  m*/

        int ratio = Math.max(bWidth / vWidth, bHeight / vHeight);
        int ratioAfterRotate = Math.max(bHeight / vWidth, bWidth / vHeight);

        return Math.min(ratio, ratioAfterRotate);
    }
}

Related Tutorials