from Dp To Pixels - Java 2D Graphics

Java examples for 2D Graphics:Pixel

Description

from Dp To Pixels

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int dp = 2;
        float density = 2.45678f;
        System.out.println(fromDpToPixels(dp, density));
    }/*from   ww w  .j  ava2  s  .  c  om*/

    public static int fromDpToPixels(int dp, float density) {
        return (int) (dp * density + 0.5f);
    }
}

Related Tutorials