()
| 300 | } |
| 301 | |
| 302 | run() { |
| 303 | let inputPaths = this.inputPaths; |
| 304 | let c = inputPaths.length; |
| 305 | let width, height; |
| 306 | let buffer; |
| 307 | let offset = 0; |
| 308 | let y = 0; |
| 309 | if (c == 1) { |
| 310 | let pngPath = inputPaths[0]; |
| 311 | let png = new PNG(this.readFileBuffer(pngPath)); |
| 312 | if (!this.checkPNG(png)) |
| 313 | throw new Error("'" + pngPath + "': invalid PNG format!"); |
| 314 | let pngWidth = png.width; |
| 315 | let pngHeight = png.height; |
| 316 | if ((this.rotation == 0) || (this.rotation == 180)) { |
| 317 | width = this.pad(pngWidth); |
| 318 | height = pngHeight; |
| 319 | } |
| 320 | else { |
| 321 | width = pngWidth; |
| 322 | height = this.pad(pngHeight); |
| 323 | } |
| 324 | buffer = new Uint8Array(width * height * 4); |
| 325 | while (y < pngHeight) { |
| 326 | let x = 0; |
| 327 | this.transferLine(png, buffer, offset); |
| 328 | offset += (pngWidth * 4); |
| 329 | x += pngWidth; |
| 330 | while (x < width) { |
| 331 | buffer[offset++] = 0; |
| 332 | buffer[offset++] = 0; |
| 333 | buffer[offset++] = 0; |
| 334 | buffer[offset++] = 255; |
| 335 | x++; |
| 336 | } |
| 337 | y++; |
| 338 | } |
| 339 | } |
| 340 | else { |
| 341 | let pngs = new Array(c).fill(); |
| 342 | let pngWidth, pngHeight; |
| 343 | for (let i = 0; i < c; i++) { |
| 344 | let pngPath = inputPaths[i]; |
| 345 | let png = new PNG(this.readFileBuffer(pngPath)); |
| 346 | if (!this.checkPNG(png)) |
| 347 | throw new Error("'" + pngPath + "': invalid PNG format!"); |
| 348 | if (i == 0) { |
| 349 | pngWidth = png.width; |
| 350 | pngHeight = png.height; |
| 351 | } |
| 352 | else { |
| 353 | if (pngWidth != png.width) |
| 354 | throw new Error("'" + pngPath + "': invalid width!"); |
| 355 | if (pngHeight != png.height) |
| 356 | throw new Error("'" + pngPath + "': invalid height!"); |
| 357 | } |
| 358 | pngs[i] = png; |
| 359 | } |
nothing calls this directly
no test coverage detected