1
0
mirror of https://github.com/kettek/png-js synced 2025-03-14 06:24:30 -07:00

Fix toImageData to actually use passed palette

This commit is contained in:
kts of kettek (Gliese) 2019-01-15 01:14:15 -08:00
parent 39e8ee8f25
commit cedcb60245

View File

@ -294,7 +294,8 @@ class IndexedPNG {
return ret; return ret;
} }
async toImageData(palette = this.decodePalette()) { async toImageData(options) {
const palette = options.palette || this.decodedPalette
if (!this.decodedPixels) { if (!this.decodedPixels) {
await this.decode() await this.decode()
} }
@ -308,6 +309,7 @@ class IndexedPNG {
pixels[j++] = palette[index+2] // B pixels[j++] = palette[index+2] // B
pixels[j++] = palette[index+3] // A pixels[j++] = palette[index+3] // A
} }
console.log(pixels)
return new ImageData(pixels, this.width) return new ImageData(pixels, this.width)
} }