I guess I'm not setting the array correctly or something, but this throws a "nullreferenceexception" when it gets to the line where it actually sets the new array value to the color_table array (should be the 7th and 12th lines of what you see below). How should I write this so that it works?
public int[] colors = new int[] { 0, 255, 0, 255, 0, 255 };
private int[][] color_table;
public void setcolors()
{
this.color_table[0] = new int[] { 0, 0, 0 };
for (int i = 1; i <= this.precision; i++) {
int r = (((this.colors[1] - this.colors[0]) * ((i - 1) / (this.precision - 1))) + this.colors[0]);
int g = (((this.colors[3] - this.colors[2]) * ((i - 1) / (this.precision - 1))) + this.colors[2]);
int b = (((this.colors[5] - this.colors[4]) * ((i - 1) / (this.precision - 1))) + this.colors[4]);
this.color_table[i] = new int[] { r, g, b };
}
}
I've heard something about that you MUST initialize an array with its length before using it, but a) I don't know how to do that and b) I'm not sure if it's problem. The issue there is that I don't know what the array length is going to be. I tried this to no avail:
private int[this.precision][3] color_table;
Thanks!