# HG changeset patch # User Xeli # Date 1337640086 -7200 # Node ID 1982e702ed2fb2fef90b62e2517b407f9ba9381b # Parent aacb90365d3d0e029d0569837ab9a0d97aff8ec2 android: possible fix for bitmap recycle errors diff -r aacb90365d3d -r 1982e702ed2f project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java Tue May 22 00:40:43 2012 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java Tue May 22 00:41:26 2012 +0200 @@ -32,6 +32,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import java.nio.ByteBuffer; public class FrontendDataUtils { @@ -95,8 +96,11 @@ Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap int width = b.getWidth(); if(b.getHeight() > width){//some pictures contain more 'frames' underneath each other, if so we only use the first frame - Bitmap tmp = Bitmap.createBitmap(b, 0, 0, width, width); - b.recycle(); + Bitmap tmp = Bitmap.createBitmap(width, width, b.getConfig()); + int[] pixels = new int[width * width]; + b.getPixels(pixels, 0,width,0,0,width,width); + tmp.setPixels(pixels,0,width,0,0,width,width); + b.recycle(); b = tmp; } map.put("img", b);