나는 bitmap
의 품질을 잃지 않고 비트 맵의 높이와 너비를 줄이기 위해 인터넷에서 bitmap
을 다운로드했습니다. 이것을 달성하는 방법.비트 맵의 높이와 너비를 최소화하면 화질이 왜곡됩니다.
인터넷에서 비트 맵을 다운로드하는 방법입니다.
URL url_1 = null;
try {
url_1 = new URL(vmImageUrl);
bmp = BitmapFactory.decodeStream(url_1.openConnection().getInputStream());
} catch (Exception e) {
Log.v("Error while downloading bitmap from url", e.getMessage());
나는 이와 같이 크기를 조정했습니다.
Bitmap.createScaledBitmap(bmp, convertDpToPixel(140, context), convertDpToPixel(35, context), false);
이 방법은 dp 단위를 동등한 장치 특정 값 (픽셀 단위)으로 변환합니다.
public static int convertDpToPixel(float dp,Context context)
{
Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
int px = (int) (dp * (metrics.densityDpi/160f));
return px;
}
내 질문은 캔버스에 비트 맵을 그리지 않습니다. 높이와 너비를 줄인 후 품질 비트 맵이 필요합니다. –
괜찮 았어.로드하기 전에 비트 맵에 선호되는 RGB를 설정할 수있다. BitmapFactory.Options 옵션 = 새로운 BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.RGB_565; \t \t \t bitmap = BitmapFactory.decodeStream (is, null, options); – cotsios