I need to downscale my images (+- 2500px one side) to show them on my devices in my app. But I've got one problem. If I downscale the images with my code (a bit further down) the images are displayed but the side is cut-off. The height of the image is perfect with my code. I'm downscaling my images with this code:
static public Bitmap scaleToFill(Bitmap b, int width, int height) {
float factorH = height / (float) b.getWidth();
float factorW = width / (float) b.getWidth();
float factorToUse = (factorH > factorW) ? factorW : factorH;
return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorToUse), (int) (b.getHeight() * factorToUse), false);
}
The height and width I'm getting with this:
WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
The image is viewed in a ImageView with ScaleType CENTER_CROP. I hope someone can help me with this! Thanks in advance!