/** * Das Seitenverhältnis nimmt den Maximalwert an, um das Bild zu skalieren. * * @param Bitmap geladenes Bild * @param widthSize Die Breite des Bildes nach der Skalierung, im Allgemeinen die Breite des Bildschirms. * @param heightSize Die Höhe des Bildes nach der Skalierung, im Allgemeinen die Höhe des Bildschirms. */ public static Bitmap ScaleImgMax(Bitmap bitmap, int widthSize, int heightSize) { int bmpW = bitmap.getWidth(); int bmpH = bitmap.getHeight(); float scaleW = ((float) widthSize) / bmpW; float scaleH = ((float) heightSize) / bmpH; // Nehmen Sie das maximale Verhältnis von Breite und Höhe, um das Bild zu vergrößern float max = Math.max(scaleW, scaleH); Matrixmatrix = neue Matrix(); Matrix.postScale(max, max); return Bitmap.createBitmap(bitmap, 0, 0, bmpW, bmpH, matrix, true); }
/** * Breite und Höhe werden separat gestreckt * * @param Bitmap geladenes Bild * @param widthSize Die Breite des Bildes nach der Skalierung, im Allgemeinen die Breite des Bildschirms. * @param heightSize Die Höhe des Bildes nach der Skalierung, im Allgemeinen die Höhe des Bildschirms. */ public static Bitmap ScaleImgMax(Bitmap bitmap, int widthSize, int heightSize) { int bmpW = bitmap.getWidth(); int bmpH = bitmap.getHeight(); float scaleW = ((float) widthSize) / bmpW; float scaleH = ((float) heightSize) / bmpH; Matrixmatrix = neue Matrix(); matrix.postScale(scaleW, scaleH); return Bitmap.createBitmap(bitmap, 0, 0, bmpW, bmpH, matrix, true); }