Ich habe eine benutzerdefinierte Ansicht (WorldMapView) und eine Karte ziehbar (3209x1287, PNG, 64-Bit-Farbe, 1,33 M), und ich binWie komprimiere ich Bitmap im PNG-Format?
bekommenjava.lang.RuntimeException: Leinwand: Der Versuch, zu groß zu ziehen (148679388bytes) Bitmap.
Ich versuchte, so zu komprimieren.
WorldMapView worldMapView = (WorldMapView) itemView.findViewById(R.id.map_of_world);
Bitmap bitmap = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.map)).getBitmap();
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
worldMapView.setImageBitmap(decoded);
Aber wenn Sie mit PNG-Format, dann wird es nicht Ihr Bild komprimieren, weil PNG ein verlustfreies Format ist, so kann jemand bitte eine Lösung vorschlagen?
Vielen Dank im Voraus.
'Wenn Sie jedoch das PNG-Format verwenden, wird das Bild nicht komprimiert, da PNG ein verlustfreies Format ist. Sie haben sich selbst geantwortet. –