다음 방법을 사용하여 Android에서 이미지 크기를 조정합니다.Android에서 이미지 크기 조정
public Bitmap resize(Bitmap img, int Width, int Height) {
int width = img.getWidth();
int height = img.getHeight();
int newWidth = (int) Width;
int newHeight = (int) Height;
// calculate the scale - in this case = 0.4f
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
// createa matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// rotate the Bitmap
//matrix.postRotate(45);
// recreate the new Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(img, 0, 0, width, height, matrix, true);
return resizedBitmap;
}
대부분의 Android 기기에서 정상적으로 작동합니다. 그러나 일부 장치에서는 크기가 조정 된 이미지가 표시되지 않습니다. 어떻게 해결할 수 있을까요?
정적 이미지 또는 서버 이미지에 이것을 호출 하시겠습니까 ?? – Piyush
좋은 시작을 한 것처럼 들리 네! 비트 맵이 어떻게 보이는지/보이지 않는지에 대해 좀 더 정확하게 표현할 수 있습니까? 예 : 이미지 뷰, 드로어 블 또는 캔버스에 직접 그려지는 것입니까? – Tom
이미지가 표시되지 않는다는 것은 무엇을 의미합니까? 또한 두 비트 맵의 밀도가 동일하게 설정되어 있습니까? –