project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java
equal
deleted
inserted
replaced
30 import org.hedgewars.hedgeroid.Datastructures.Map.MapType; |
30 import org.hedgewars.hedgeroid.Datastructures.Map.MapType; |
31 |
31 |
32 import android.content.Context; |
32 import android.content.Context; |
33 import android.graphics.Bitmap; |
33 import android.graphics.Bitmap; |
34 import android.graphics.BitmapFactory; |
34 import android.graphics.BitmapFactory; |
|
35 import java.nio.ByteBuffer; |
35 |
36 |
36 public class FrontendDataUtils { |
37 public class FrontendDataUtils { |
37 |
38 |
38 |
39 |
39 public static ArrayList<Map> getMaps(Context c){ |
40 public static ArrayList<Map> getMaps(Context c){ |
93 HashMap<String, Object> map = new HashMap<String, Object>(); |
94 HashMap<String, Object> map = new HashMap<String, Object>(); |
94 map.put("txt", s); |
95 map.put("txt", s); |
95 Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap |
96 Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap |
96 int width = b.getWidth(); |
97 int width = b.getWidth(); |
97 if(b.getHeight() > width){//some pictures contain more 'frames' underneath each other, if so we only use the first frame |
98 if(b.getHeight() > width){//some pictures contain more 'frames' underneath each other, if so we only use the first frame |
98 Bitmap tmp = Bitmap.createBitmap(b, 0, 0, width, width); |
99 Bitmap tmp = Bitmap.createBitmap(width, width, b.getConfig()); |
99 b.recycle(); |
100 int[] pixels = new int[width * width]; |
|
101 b.getPixels(pixels, 0,width,0,0,width,width); |
|
102 tmp.setPixels(pixels,0,width,0,0,width,width); |
|
103 b.recycle(); |
100 b = tmp; |
104 b = tmp; |
101 } |
105 } |
102 map.put("img", b); |
106 map.put("img", b); |
103 data.add(map); |
107 data.add(map); |
104 } |
108 } |