I am trying to create a HeatMap
witch is displayed in an ImageView
in my Android
application.
I get the data as an .csv
file and write it to an multidimensional array
.
The Array
contains data (0 to 499)for each Pixel
of a 100x400 Image.
I created an java
class to get a colour gradient array from 5 colours and get back an (int) Array[500]
with the sRGB colors.
Now I am stuck on how to create a Bitmap
(or something like that) with the data and the corresponding Colour from the Array
.
Tried to understand the GoogleMaps Heatmap
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 Array
witch contains the specific indice for the colour Array
of each pixel in Data and is created in another method.
private void drawData()
{
bufferedImage = new BufferedImage(data.length,data[0].length, BufferedImage.TYPE_INT_ARGB);
bufferedGraphics = bufferedImage.createGraphics();
for (int x = 0; x < data.length; x++)
{
for (int y = 0; y < data[0].length; y++)
{
bufferedGraphics.setColor(colors[dataColorIndices[x][y]]);
bufferedGraphics.fillRect(x, y, 1, 1);
}
}
try {
File outputfile = new File("C:/.../HeatMap.png");
ImageIO.write(bufferedImage, "png", outputfile);
} catch (IOException e) {
// handle exception;
}
}
The Code is written by Matthew Beckler (https://www.mbeckler.org/heatMap/).