Beginner needs help with image mapping
in
Programming Questions
•
1 year ago
So I have this nearly figured out, I am trying to source data from a .csv, to map to an image (.png) preferably, it is very close right now, my only problem is that the image comes back with a diagonal from top-left to bottom-right, where above is sourcing the data properly and below is black(background) I know some one out that can solve this in seconds, thank you very much
martymart
int rows, cols;
int[][] data; // this is the 2D-array, where the data shall be stored
void setup() {
String[] lines = loadStrings("CSV_100X100.csv"); // lets assume, you have comma-seperated values
rows = lines.length;
cols = split(lines[0], ',').length;
// initialize data-array
data = new int[cols][rows];
// parse data-file
for (int row =0; row<lines.length; row++) {
// split current line by ','
String[] values = split(lines[row],',');
// loop through the values of that line
for (int col =0; col<values.length; col++){
// store value in your array
data[col][row] = int(values[col]);
stroke(data[row][col]);
point(row, col);
}
}
}
1