I have a pixel
input and i want to convert it to DP
using Java.
what formula should i use? or there is an external library than i can use!?
This code is common in android sdk. Is there a way to use it outside of Android?
public static float convertPixelsToDp(float px){
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float dp = px / (metrics.densityDpi / 160f);
return Math.round(dp);
}
Iam not using it for android i use it in a java application so i want to know how to do it in java not android.