I have to create a BufferedImage from a list of float array. With one float array i create one pixel width of the image. The total width is 500 px. The float array list’s size can be up to 10000 float array.
The image I built is some sort of history, so it is display in a time length graph. For example if the history is 6min the graph goes from 3 to -3 on the x axes, and the image should be centered against a middle point between 3 and -3.
The title says “interpolate”, but I’m not sure if the solution involves interpolation.
- How can I choose float array from the list if the list size is over 500?
- How can I split the list if its size is less than 500?
1 & 2) You have to calculate 500 pixels / size. That’s how many pixels you use for each value. If you have more than 500 float values, each value will take less than a pixel width. If you have less than 500 values, each value will take more than a pixel width.
Let’s say you have 700 float values. Each value will take 5/7 of a pixel. You can’t plot partial pixels, but you can sum and round to determine which value to plot.
and so on, until you’ve plotted all the values.
Let’s say you have 300 float values. Each value will take 5/3 of a pixel, or almost 2 pixels. Again, you sum and round to determine which values to plot.
and so on, until you’ve plotted all the values.