shaozilee / bmp-js

A pure javascript BMP encoder and decoder for node.js
MIT License
86 stars 45 forks source link

Add support for BGR/RGB #16

Open pablodgonzalez opened 6 years ago

pablodgonzalez commented 6 years ago

both formats are valids and many software open those formats correctly

LinusU commented 6 years ago

Just tried this library and are getting some strange colors, could this be the cause?

This is the file: 905.bmp.zip

This is how preview on macOS renders it: 905

pablodgonzalez commented 6 years ago

Yes! it is. I've have not time to research. I don't know if it is BGR/RGB or if it is BMP 32bits without alpha. I've hope somebody know about it.

LinusU commented 6 years ago

Hehe, actually, it turns out that the image is just a common normal bmp. The problem is that I tried to use the output as an ImageData, which expects the data to be RGBA, but bmp-js outputs it as BGRA.

I was looking thru the file with a hex-editor and couldn't for the life of me figure out where it would be specified that it would have a non-standard color order 😂

mooyoul commented 6 years ago

19 provides solution of this ;)

also, i have forked version of bmp-js to prevent incorrect color issues. See: https://github.com/shaozilee/bmp-js/pull/19#issuecomment-418508638