java - Android - Draw on a Bitmap -


good morning. i'm writing app display , analyze gpr maps. unfortunately maps i've been given txt files char 0x00 represents black , 0xff represents white. app it's @ stage , i've managed display files on screen using following code:

public class drawmap extends view {     // ...     public void ondraw(canvas canvas) {         super.ondraw(canvas);          this.paint.setstyle(paint.style.fill);         this.paint.setstrokewidth(1);          (int x = 0; x < this.map.getsize(); x++) {             (int y = 0; y < this.map.getsize(); y++) {                 char val = this.map.getpixel(x, y);                 this.paint.setcolor(color.argb(0xff, val, val, val));                 canvas.drawpoint(10+x, 10+y, this.paint);             }         }     } } 

since size (width x height) of map may vary, easier draw map on bitmap, or that, first, , display fit size of screen. don't know how achieve that. need help, please.

try this:

int w = width_px, h = height_px;  bitmap.config conf = bitmap.config.rgb_565; bitmap bmp = bitmap.createbitmap(w, h, conf); canvas canvas = new canvas(bmp);  // ready draw on bitmap through canvas 

source: creating empty bitmap , drawing though canvas in android

hope helps!


Comments