Add gimp color palette exporter

This commit is contained in:
MathemanFlo
2022-03-27 11:22:26 +02:00
parent ef3901320c
commit 35ea0782dd
2 changed files with 26 additions and 2 deletions
+4 -2
View File
@@ -32,6 +32,7 @@ import arm.io.ImportBlend;
import arm.io.ImportMesh;
import arm.io.ImportTexture;
import arm.io.ExportArm;
import arm.io.ExportGpl;
import arm.node.NodesBrush;
import arm.Viewport;
import arm.ProjectFormat;
@@ -574,10 +575,11 @@ class Project {
}
public static function exportSwatches() {
UIFiles.show("arm", true, false, function(path: String) {
UIFiles.show("arm,gpl", true, false, function(path: String) {
var f = UIFiles.filename;
if (f == "") f = tr("untitled");
ExportArm.runSwatches(path + Path.sep + f);
if (f.endsWith(".gpl")) ExportGpl.run(path + Path.sep + f, f.substring(0,f.lastIndexOf(".")), Project.raw.swatches);
else ExportArm.runSwatches(path + Path.sep + f);
});
}
+22
View File
@@ -0,0 +1,22 @@
package arm.io;
import haxe.io.BytesOutput;
import arm.ProjectFormat;
class ExportGpl {
public static function run(path: String, name: String, swatches: Array<TSwatchColor>) {
var o = new BytesOutput();
o.bigEndian = false;
o.writeString("GIMP Palette\n");
o.writeString("Name: " + name + "\n");
o.writeString("# armorpaint.org\n");
o.writeString("#\n");
for (swatch in swatches) {
o.writeString(Std.string(swatch.base.Rb) + " " + Std.string(swatch.base.Gb) + " " + Std.string(swatch.base.Bb) + "\n");
}
Krom.fileSaveBytes(path, o.getBytes().getData(), o.getBytes().length);
}
}