care about cli when uploading images with admintools

This commit is contained in:
HF 2020-03-27 00:36:45 +01:00
parent f47b2a3a20
commit 460040ec00

View File

@ -36,12 +36,13 @@ export async function imageABGR2Canvas(
`Loading image with dim ${width}/${height} to ${x}/${y}/${canvasId}`,
);
const canvas = canvases[canvasId];
const palette = new Palette(canvas.colors);
const canvasMinXY = -(canvas.size / 2);
const { colors, cli, size } = canvas;
const palette = new Palette(colors);
const canvasMinXY = -(size / 2);
const imageData = new Uint32Array(data.buffer);
const [ucx, ucy] = getChunkOfPixel(canvas.size, x, y);
const [lcx, lcy] = getChunkOfPixel(canvas.size, x + width, y + height);
const [ucx, ucy] = getChunkOfPixel(size, x, y);
const [lcx, lcy] = getChunkOfPixel(size, x + width, y + height);
logger.info(`Loading to chunks from ${ucx} / ${ucy} to ${lcx} / ${lcy} ...`);
let chunk;
@ -64,8 +65,8 @@ export async function imageABGR2Canvas(
const clr = imageData[clrX + clrY * width];
const clrIndex = (wipe || protect)
? palette.abgr.indexOf(clr)
: palette.abgr.indexOf(clr, 2);
if (~clrIndex) {
: palette.abgr.indexOf(clr, cli);
if (clrIndex !== -1) {
const pixel = (protect) ? (clrIndex | 0x80) : clrIndex;
chunk[cOff] = pixel;
pxlCnt += 1;