unfortunately I'm trying to create Bitmap object, from not typical data source ...
my problem:
- I'm painting map tiles onto screen (tiles are 120 x 120px - 14400px)
- from map file with tiles I obtain
1. palette - array of int int[256] - 256 colors
2. image data, deflated by ZLIB, after decopress (by Inflater) i receive 14400b array of byte[], that contain indexes of colors in color array
currently i'm not using JNI so to create Bitmap I use this code:
Using java Syntax Highlighting
- // used variables
- int[] palette = new int[256]; // 256 int colors
- byte[] imageBuffer = new byte[120 * 120]; // fill with loaded data
- int[] imageData = new int[120 * 120]; // here i create new image data
- // 12 ms / image - stupid and very slow cycle to fill image data with right colors
- for (int i = 0; i < 14400; i++) {
- imageData[i] = palette[imageBuffer[i] & 0xFF];
- }
- Bitmap bitmap = Bitmap.createBitmap(imageData, 120, 120, Bitmap.Config.RGB_565);
Parsed in 0.011 seconds, using GeSHi 1.0.8.4
- so, after loading image data, I have to create new array filled with right color for every pixel. This is very slow (cycle with 14400 computes for every image). I'm testing it on motorola milestone and cause of big resolution, I need around 40 images to cover whole screen. Because this is map application, so you move with tiles, this method is very slow. Because I'm not much familiar with C++, I'm asking if anyone have any idea how to make it faster, probably with using of JNI.
- best solution should be direct creating of Bitmap from palette and compressed datas, but this is surely not in API. I also tryed to create PNG image (directly from loaded bytes) which have similar PLTE and IDAT part, but this IDAT do not containg filter byte '0' in every image row.
any suggestions are very very welcome, thank you ...