files = findfile("*.lut")
colornames = ["char *colornames[] = {"]
hhh = files
replace hhh, ".lut", ""
colornames += hhh
for i=2, nelements(colornames) colornames[i] = "\"" + colornames[i] + "\","
colornames += "};"
colormaps = fits(256, 3, nelements(colornames)-2)
for i=1, nelements(colornames)-2 {
hhh = import(files[i])
colormaps[*,*,i] = hhh * 255
}
for i=1, naxis1(colormaps) {
  for j=1, naxis2(colormaps) {
    for k=1, naxis3(colormaps) {
      colormaps[i,j,k] = round(colormaps[i,j,k])
    }
  }
}
colornames += ""
colornames += "unsigned char colormaps[] = {"
for k=1, naxis3(colormaps) {
  for j=1, naxis2(colormaps) {
    hhh = ""
    for i=1, naxis1(colormaps) {
      hhh += sprintf("%.0f,", colormaps[i,j,k])
    }
    if (k == naxis3(colormaps) && j == naxis2(colormaps)) colornames += hhh[1:strlen(hhh)-1]
    else colornames += hhh
  }
}
colornames += "};"

export "../lut.cpp", colornames
