-
Notifications
You must be signed in to change notification settings - Fork 47
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
Some improvements in the handling of headers and 16-/24-/32-bit data #19
base: master
Are you sure you want to change the base?
Conversation
… and make it more spec-compliant, add RGBA output byte order option
Hey @jeremejevs, Thanks for your amazing work! I was looking for solution using bitmap as input on sharp. anyway there are some issue still remains,
so i made some improvements based on your work: it resolves descried issues, provides typescript definition. check it out if you need ;) |
@mooyoul Thanks for picking this up, looks good! Make sure to put Honestly, this whole lib could use a rewrite in TS, I didn't do it to save some time (just wanted to get a single BMP-to-PNG test going, no production needs) and to keep the diff to a minimum (which appears to have been a waste of time, still not reviewed/merged). |
@jeremejevs I run https://github.com/oliver-moran/jimp/ and there are a bunch of features the community wants from BMP encoding/decoding. Would you like to work together to create a typescript bmp-js? |
@jeremejevs working here https://github.com/hipstersmoothie/bmp-js/tree/ts. I'm gonna try to integrate some of your code |
@jeremejevs I have now integrated your code into the TS bmp-js |
@shaozilee would you be open to merging a typescript rewrite? or should i maintain a new version of |
@hipstersmoothie Hi, I think I wouldn't mind working on this, but we don't depend on this module in production at work, so there's no incentive to invest billed hours into it, and I'm currently focused on other things in my free time, so sorry, it's a no at this time. I see that you went ahead and have done it yourself in a couple of hours though, so no loss 😛 I've taken a quick glance at your branch, and there are a few things I would refactor more radically, but seems good otherwise! Why didn't you base it on @mooyoul's fork though? |
@jeremejevs ooops. guess I'm gonna loose another few hours. I'll probably make a PR there. |
Oh, it's not a big diff, but yeah, it does have a few useful fixes. |
@jeremejevs I'd appreciate it if you could take a look at https://github.com/hipstersmoothie/bmp-js. I have implemented encoding at all the bit sizes. Anything is helpful! |
@hipstersmoothie Skimmed through the decoder, looks alright! One quick suggestion I have is to inline |
Lots of changes, but most of them are just simplifications.
The major ones are the automation of extra header field detection and more spec-compliance in data parsing. For example, the alpha mask actually isn't included in
BITMAPINFOHEADER
/BITMAPV2INFOHEADER
headers, unless asked byBI_ALPHABITFIELDS
, unlike what is assumed in the currentmaster
(this is what made me fix this library, since I had to deal with images which were crashing because of this). Another improvement is the mask handling, especially so in the 16-bit mode: it's completely universal now, and there's no need in the 15-bit mode anymore, nor inis_with_alpha
.Also added a
toRGBA
option, switching the output to big endian RGBA, making it compatible with other libraries, likepngjs
.Using the Wikipedia article as the specification, for the lack of a better centralized doc.
Currently published as
@jeremejevs/bmp-js
, for those who need this ASAP.