get Picture Scale - Android Media

Android examples for Media:Picture

Description

get Picture Scale

Demo Code


//package com.java2s;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {
    public static double getPicScale(Resources res, int id) {
        // TODO Auto-generated method stub
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        Bitmap bmp = BitmapFactory.decodeResource(res, id, options);
        double height = options.outHeight;
        double width = options.outWidth;
        return height / width;
    }//w w w.  j  a  v  a  2s.  c om
}

Related Tutorials