Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current repo prints images with inverted colors #408

Open
ferminc opened this issue Oct 1, 2022 · 1 comment
Open

Current repo prints images with inverted colors #408

ferminc opened this issue Oct 1, 2022 · 1 comment

Comments

@ferminc
Copy link

ferminc commented Oct 1, 2022

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

@ferminc
Copy link
Author

ferminc commented Oct 1, 2022

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 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant