while (i < matrix.width() && k < matrix.height()) { rgb[k] = matrix.get(0, i); i++; if (i == matrix.width()) { i =