Bitmap Of X Cm's Width And Y Cm's Height
I am taking a picture using camera in my app and will email the picture to a certain email address. now i want the emailed picture's physical dimensions to be 10cm's in width and 8
Solution 1:
This?
publicstaticintmm2pixels(int val, Context current) {
DisplayMetricsmetrics= current.getResources().getDisplayMetrics();
return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, val, metrics);
}
Solution 2:
i have used WarrenFaiths directions and came up with the below solution.
DisplayMetricsmetrics= activity.getResources().getDisplayMetrics();
totalDIP_X = metrics.xdpi;
totalDIP_Y = metrics.ydpi;
totalDIP_X and totalDIP_Y represent the total number of DIPs per inch on the phone.
so if you want the bitmap to be 5cms*5cms on phone, which is equivalent to 1.968inch*1.968inch, we should use the below code.
imageView1.setImageBitmap(Bitmap.createScaledBitmap (aBitmap, (int)(1.968*totalDIP_X), (int)(1.968*totalDIP_Y), false));
Post a Comment for "Bitmap Of X Cm's Width And Y Cm's Height"