add rgb bands for thumb/preview as placeholder
This commit is contained in:
parent
127ca791da
commit
9ab310d2a3
3 changed files with 53 additions and 5 deletions
|
|
@ -31,6 +31,11 @@ self.ArrayWriter = class ArrayWriter {
|
||||||
this.array[this.pos++] = v & 0xff;
|
this.array[this.pos++] = v & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeBytes(bytes) {
|
||||||
|
this.array.appendAll(bytes);
|
||||||
|
this.pos += bytes.length;
|
||||||
|
}
|
||||||
|
|
||||||
toBuffer() {
|
toBuffer() {
|
||||||
return new Uint8ClampedArray(this.array).buffer;
|
return new Uint8ClampedArray(this.array).buffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,12 +107,32 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate thumb, preview1, preview2
|
// generate thumb, preview1, preview2
|
||||||
|
let thumb = [];
|
||||||
|
for (let x=0; x<116; x++) {
|
||||||
|
for (let y=0; y<116; y++) {
|
||||||
|
let val = 1 << Math.floor(x / 7.25);
|
||||||
|
thumb.push((val >> 8) & 0xff);
|
||||||
|
thumb.push(val & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let preview1 = [];
|
||||||
|
for (let x=0; x<290; x++) {
|
||||||
|
for (let y=0; y<290; y++) {
|
||||||
|
let val = 1 << Math.floor(x / 18.125);
|
||||||
|
preview1.push((val >> 8) & 0xff);
|
||||||
|
preview1.push(val & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let preview2 = preview1;
|
||||||
|
|
||||||
let file = CXDLP.export({
|
let file = CXDLP.export({
|
||||||
settings,
|
settings,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
slices
|
slices,
|
||||||
|
thumb,
|
||||||
|
preview1,
|
||||||
|
preview2
|
||||||
});
|
});
|
||||||
ondone({
|
ondone({
|
||||||
width: width,
|
width: width,
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,29 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output.write_bytes = function(array, len) {
|
||||||
|
if (!array) {
|
||||||
|
output.skip(len);
|
||||||
|
} else if (array.byteLength) {
|
||||||
|
if (len !== array.byteLength) {
|
||||||
|
throw `invalid array length: ${array.byteLength} != ${len}`;
|
||||||
|
}
|
||||||
|
// ArrayBuffer
|
||||||
|
let read = new DataReader(array);
|
||||||
|
for (let i=0; i<array.byteLength; i++) {
|
||||||
|
output.writeU8(read.readU8());
|
||||||
|
}
|
||||||
|
} else if (array.length) {
|
||||||
|
if (len !== array.length) {
|
||||||
|
throw `invalid array length: ${array.length} != ${len}`;
|
||||||
|
}
|
||||||
|
// standard array
|
||||||
|
output.writeBytes(array);
|
||||||
|
} else {
|
||||||
|
throw "invalid byte array";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let layers = this.layers;
|
let layers = this.layers;
|
||||||
this.layer_count = layers.length;
|
this.layer_count = layers.length;
|
||||||
output.write_string(this.magic1);
|
output.write_string(this.magic1);
|
||||||
|
|
@ -184,11 +207,11 @@
|
||||||
output.writeU16(this.res_y);
|
output.writeU16(this.res_y);
|
||||||
output.writeU32(this.height);
|
output.writeU32(this.height);
|
||||||
output.skip(60);
|
output.skip(60);
|
||||||
output.skip(26912); // thumb
|
output.write_bytes(this.thumb, 26912); // thumb
|
||||||
output.writeU16(data_term);
|
output.writeU16(data_term);
|
||||||
output.skip(168200); // preview1
|
output.write_bytes(this.preview1, 168200); // preview1
|
||||||
output.writeU16(data_term);
|
output.writeU16(data_term);
|
||||||
output.skip(168200); // preview1
|
output.write_bytes(this.preview2, 168200); // preview1
|
||||||
output.writeU16(data_term);
|
output.writeU16(data_term);
|
||||||
output.write_string(this.dim_x, true);
|
output.write_string(this.dim_x, true);
|
||||||
output.write_string(this.dim_y, true);
|
output.write_string(this.dim_y, true);
|
||||||
|
|
@ -274,7 +297,7 @@
|
||||||
cxdlp.layer = process.slaSlice.toFixed(5);
|
cxdlp.layer = process.slaSlice.toFixed(5);
|
||||||
cxdlp.thumb = thumb;
|
cxdlp.thumb = thumb;
|
||||||
cxdlp.preview1 = preview1;
|
cxdlp.preview1 = preview1;
|
||||||
cxdlp.preview1 = preview2;
|
cxdlp.preview2 = preview2;
|
||||||
cxdlp.light_on = process.slaLayerOn;
|
cxdlp.light_on = process.slaLayerOn;
|
||||||
cxdlp.light_off = process.slaLayerOff;
|
cxdlp.light_off = process.slaLayerOff;
|
||||||
// cxdlp.light_pwm = 255;
|
// cxdlp.light_pwm = 255;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue