import_gpl.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function import_gpl_run(path: string, replace_existing: bool) {
  2. let b: buffer_t = data_get_blob(path);
  3. // let swatches: TSwatchColor[] = [];
  4. // let str: string = sys_buffer_to_string(b);
  5. // let lines: string[] = string_split(str, "\n");
  6. // let view: buffer_view_t = buffer_view_create(b);
  7. // // GIMP's color palette importer: https://gitlab.gnome.org/GNOME/gimp/-/blob/gimp-2-10/app/core/gimppalette-load.c#L39
  8. // if (!starts_with(lines[0], "GIMP Palette")) {
  9. // console_error(tr("Not a valid GIMP color palette"));
  10. // return;
  11. // }
  12. // let delimiter: string = ~/\s+/ig;
  13. // for (let line of lines) {
  14. // if (starts_with(line, "Name:")) continue;
  15. // else if (starts_with(line, "Columns:")) continue;
  16. // else if (starts_with(line, "#")) continue;
  17. // else {
  18. // let tokens: string[] = string_split(delimiter, line);
  19. // if (tokens.length < 3) continue;
  20. // let swatch: TSwatchColor = makeSwatch(Color.fromBytes(any_to_string(tokens[0]), any_to_string(tokens[1]), any_to_string(tokens[2])));
  21. // array_push(swatches, swatch);
  22. // }
  23. // }
  24. // if (replaceExisting) {
  25. // raw.swatches = [];
  26. // if (swatches.length == 0) { // No swatches contained
  27. // array_push(raw.swatches, makeSwatch());
  28. // }
  29. // }
  30. // if (swatches.length > 0) {
  31. // for (let s of swatches) {
  32. // array_push(raw.swatches, s);
  33. // }
  34. // }
  35. }