Ich versuche, eine Bitmap zu zeichnen (im Hintergrund) auf der Leinwand des SurfaceOOM: eine 3MB .png-Datei auf einer Leinwand Zeichnung
Ich habe versucht:
Drawable bg = ContextCompat.getDrawable(surfaceView.getContext(), R.drawable.bg);
bg.draw(canvas);
und dann habe ich versucht:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = (int) (1600/width); //since the width of the image is 1600px
BitmapFactory.decodeResource(surfaceView.getResources(), R.drawable.bg, options);
und beide Ergebnis in der gleichen OOM Exception
java.lang.OutOfMemoryError: Failed to allocate a 147456012 byte allocation
with 1048576 free bytes and 95MB until OOM
Ich würde etwas Hilfe auf schätzen, wie mein .png Bild zu zeichnen, die 3MB (1600 * 2560)
lesen sie bitte diese: Anzeigen von Bitmaps Effizientes http: // Entwickler .android.com/intl/ru/training/Anzeige-Bitmaps/index.html –
Ich habe es gelesen, bevor ich meine Frage gepostet habe. Also habe ich options.inSampleSize –
'... mein .png Bild welches 3MB (1600 * 2560) ist', ** NEIN, es ist über 16MB **. Um genau zu sein, ** 16.384.000 Bytes ** (1600 * 2560 * 4 Bytes). –