Write out only used bytes
This commit is contained in:
@@ -55,8 +55,8 @@ plugin.drawUI = function(ui) {
|
||||
}
|
||||
}
|
||||
iterate(parsed);
|
||||
let out = iron.ArmPack.encode(parsed).b.bufferValue;
|
||||
Krom.fileSaveBytes(path.substr(0, path.length - 4) + "arm", out);
|
||||
let out = iron.ArmPack.encode(parsed);
|
||||
Krom.fileSaveBytes(path.substr(0, path.length - 4) + "arm", out.b.bufferValue, out.length + 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ plugin.drawUI = function(ui) {
|
||||
var writer = new arm.PngWriter(out);
|
||||
var data = arm.PngTools.build32RGBA(breakdown.get_width(), breakdown.get_height(), breakdown.getPixels());
|
||||
writer.write(data);
|
||||
Krom.fileSaveBytes(path + arm.Path.sep + f, out.b.buffer);
|
||||
Krom.fileSaveBytes(path + arm.Path.sep + f, out.b.buffer, out.getBytes().length);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class ExportArm {
|
||||
var raw: TSceneFormat = { mesh_datas: mesh_datas };
|
||||
var b = ArmPack.encode(raw);
|
||||
if (!path.endsWith(".arm")) path += ".arm";
|
||||
Krom.fileSaveBytes(path, b.getData());
|
||||
Krom.fileSaveBytes(path, b.getData(), b.length + 1);
|
||||
}
|
||||
|
||||
public static function runProject() {
|
||||
@@ -106,7 +106,7 @@ class ExportArm {
|
||||
};
|
||||
|
||||
var bytes = ArmPack.encode(Project.raw);
|
||||
Krom.fileSaveBytes(Project.filepath, bytes.getData());
|
||||
Krom.fileSaveBytes(Project.filepath, bytes.getData(), bytes.length + 1);
|
||||
|
||||
// Save to recent
|
||||
var recent = Config.raw.recent_projects;
|
||||
@@ -186,12 +186,12 @@ class ExportArm {
|
||||
pixels: m.image.getPixels()
|
||||
}, 1
|
||||
);
|
||||
Krom.fileSaveBytes(path.substr(0, path.length - 4) + "_icon.jpg", out.getBytes().getData());
|
||||
Krom.fileSaveBytes(path.substr(0, path.length - 4) + "_icon.jpg", out.getBytes().getData(), out.getBytes().length);
|
||||
var out = new haxe.io.BytesOutput();
|
||||
var writer = new arm.format.PngWriter(out);
|
||||
var data = arm.format.PngTools.build32RGBA(m.image.width, m.image.height, m.image.getPixels());
|
||||
writer.write(data);
|
||||
Krom.fileSaveBytes(path.substr(0, path.length - 4) + "_icon.png", out.getBytes().getData());
|
||||
Krom.fileSaveBytes(path.substr(0, path.length - 4) + "_icon.png", out.getBytes().getData(), out.getBytes().length);
|
||||
}
|
||||
|
||||
var raw = {
|
||||
@@ -208,7 +208,7 @@ class ExportArm {
|
||||
};
|
||||
|
||||
var bytes = ArmPack.encode(raw);
|
||||
Krom.fileSaveBytes(path, bytes.getData());
|
||||
Krom.fileSaveBytes(path, bytes.getData(), bytes.length + 1);
|
||||
}
|
||||
|
||||
#if (kha_metal || kha_vulkan)
|
||||
@@ -241,7 +241,7 @@ class ExportArm {
|
||||
|
||||
var bytes = ArmPack.encode(raw);
|
||||
if (!path.endsWith(".arm")) path += ".arm";
|
||||
Krom.fileSaveBytes(path, bytes.getData());
|
||||
Krom.fileSaveBytes(path, bytes.getData(), bytes.length + 1);
|
||||
}
|
||||
|
||||
static function assetsToFiles(assets: Array<TAsset>): Array<String> {
|
||||
|
||||
@@ -83,6 +83,6 @@ class ExportObj {
|
||||
|
||||
if (!path.endsWith(".obj")) path += ".obj";
|
||||
|
||||
Krom.fileSaveBytes(path, o.getBytes().getData());
|
||||
Krom.fileSaveBytes(path, o.getBytes().getData(), o.getBytes().length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ class ExportTexture {
|
||||
#end
|
||||
);
|
||||
}
|
||||
Krom.fileSaveBytes(file, out.getBytes().getData());
|
||||
Krom.fileSaveBytes(file, out.getBytes().getData(), out.getBytes().length);
|
||||
}
|
||||
|
||||
static function copyChannel(from: Bytes, fromChannel: Int, to: Bytes, toChannel: Int) {
|
||||
|
||||
@@ -250,7 +250,7 @@ class TabLayers {
|
||||
var writer = new arm.format.PngWriter(out);
|
||||
var data = arm.format.PngTools.buildGrey(l.texpaint_mask.width, l.texpaint_mask.height, l.texpaint_mask.getPixels());
|
||||
writer.write(data);
|
||||
Krom.fileSaveBytes(path + Path.sep + f, out.getBytes().getData());
|
||||
Krom.fileSaveBytes(path + Path.sep + f, out.getBytes().getData(), out.getBytes().length);
|
||||
});
|
||||
}
|
||||
if (l.fill_mask == null && ui.button(tr("To Fill Mask"), Left)) {
|
||||
|
||||
@@ -108,7 +108,7 @@ class TabTextures {
|
||||
var writer = new arm.format.PngWriter(out);
|
||||
var data = arm.format.PngTools.build32RGBA(target.width, target.height, target.getPixels());
|
||||
writer.write(data);
|
||||
Krom.fileSaveBytes(path + Path.sep + f, out.getBytes().getData());
|
||||
Krom.fileSaveBytes(path + Path.sep + f, out.getBytes().getData(), out.getBytes().length);
|
||||
target.unload();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user