title: How to pre-render a tile map for redrawing it later?
body: <p>i'm programming an Android App. I'm using a Canvas and I'm drawing a Tilemap on it by using for-loops and drawing each tile one after another.</p>
  
  <p>I want to increase the performance by render this tilemap (foreground and background individual) once and save it, so that i'm able to draw this whole map without looping threw every single tile.</p>
  
  <p>My Graphics Class looks like this:</p>
  
  <pre><code>public class AGraphics implements Graphics {
      Bitmap frameBuffer;
      Canvas canvas;
      Paint paint;
      ...
  
      public AGraphics(.., Bitmap frameBuffer) {
          this.frameBuffer = frameBuffer;
          this.canvas = new Canvas(frameBuffer);
          this.paint = new Paint();
  
      }
  
      ...
      public void drawPixmap(...){
          canvas.drawBitmap(((AndroidPixmap) pixmap).bitmap, ... );
      }
  
      ...
  
  }
  </code></pre>
  
  <p>My World Class calls the draw Pixmap Function to draw each tile:</p>
  
  <pre><code>public class World {
      ...
      public void drawForeground (float posX, float posY){
          // get Graphics ...
          for (int y = 0; y &lt; map.height; y++) {
              for (int x = 0; x &lt;map.width; x ++) {
                  // calculate Positions
                  g.draw(tileset, (int)posX, (int)posY, srcX, srcY, tilesize, tilesize);
              }
          }
      }
      ...
  }
  </code></pre>
  
  <p>Now i'm looking for a way to save the Canvas and redraw it every GameLoop at different Positions to increase the Performance. </p>
  
  <p>Any ideas or best practices? If u need some more Information pls ask!</p>
  
  <p>Thanks</p>