title: Create a 2D Heatmap in Java for Android with data from a Matrix and a spezific Color Gradient
body: <p>I am trying to create a <code>HeatMap</code> witch is displayed in an <code>ImageView</code> in my <code>Android</code> application.</p>
  <p>I get the data as an <code>.csv</code> file and write it to an multidimensional <code>array</code>.
  The <code>Array</code> contains data (0 to 499)for each <code>Pixel</code> of a 100x400 Image.
  I created an <code>java</code> class to get a colour gradient array from 5 colours and get back an <code>(int) Array[500]</code> with the sRGB colors.
  Now I am stuck on how to create a <code>Bitmap</code> (or something like that) with the data and the corresponding Colour from the <code>Array</code>.
  Tried to understand the GoogleMaps <code>Heatmap</code> example and other ones but have no clue yet.
  I am sorry if I asked an existing Question, but i have found nothing helpful yet. The code below is written in java and works with java libs (like java.awt.image.BufferedImage) witch are not accessible for Android.
  dataColorIndices is an 100x400 <code>Array</code> witch contains the specific indice for the colour <code>Array</code> of each pixel in Data and is created in another method.</p>
  <pre><code>private void drawData() 
  {
      bufferedImage = new BufferedImage(data.length,data[0].length, BufferedImage.TYPE_INT_ARGB);
      bufferedGraphics = bufferedImage.createGraphics();
      
      for (int x = 0; x &lt; data.length; x++)
      {
          for (int y = 0; y &lt; data[0].length; y++)
          {
              bufferedGraphics.setColor(colors[dataColorIndices[x][y]]);
              bufferedGraphics.fillRect(x, y, 1, 1);
          }
      }
      try {
          File outputfile = new File(&quot;C:/.../HeatMap.png&quot;);
          ImageIO.write(bufferedImage, &quot;png&quot;, outputfile);
      } catch (IOException e) {
          // handle exception;
      }
  }
  </code></pre>
  <p>The Code is written by Matthew Beckler (<a href="https://www.mbeckler.org/heatMap/" rel="nofollow noreferrer">https://www.mbeckler.org/heatMap/</a>).</p>