song940/node-escpos

Current repo prints images with inverted colors

ferminc opened this issue · 1 comments

I managed to get the current repo running, everything works well except that images (including qrimage) white pixels are printed as black and black ones as white, I guess there's a issue with the function that converts pixels to black or white?
https://github.com/song940/node-escpos/blob/v3/packages/printer/src/image.ts#L26

this is the old code:

this.data = this.data.map(function(pixel) {

I don't think there's an issue with my printer because the old version on npm prints images well

For now, I just did a quick fix it by reversing the output of the .map() function with .map( (p) => p === false )

this.data = rgbaData.map(
      ([r, g, b, a]) => a != 0 && r > 200 && g > 200 && b > 200,
    ).map( (p) => p === false )