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
x/image/bmp: support 1-bit format #29711
Comments
cc @nigeltao |
I'm open to merging 1-bit support, although if it's not too much extra work, it'd be nice to also get 2-bit and 4-bit support. |
I'll look into 2/4 bit. Is writer support needed? It does not seem that the 1/2/4 bit formats are supported in the image pkg, but I may be missing something: |
Writer support is not needed. When reading, decode to an image.Paletted or image.RGBA, even for 1/2/4 bits per pixel. |
But how to write to 1bit then? I'm also missing something. Is there any blog or example you can point us @nigeltao, please? |
If you really must write 1bpp images, then I think you're going to have to fork the bmp package, as the image package doesn't have a specific representation for 1bpp. Or write your own package. If your input is always going to be 1bpp, writing that particular subset of the BMP file format shouldn't be that complicated. If you're talking about dithering, it's already possible (using Go's standard and x libraries) to dither to a 2-element palette (black and white). You can either encode that directly, or convert that to your own 1bpp representation. |
The thing is, 1bit bmp has its use and purpose. One such is for laser engraver machines. |
I could possibly be persuaded otherwise, but I'll repeat my earlier comment: "If you really must write 1bpp images, then I think you're going to have to fork the bmp package, as the image package doesn't have a specific representation for 1bpp." Not every useful feature has to live in the Go standard library or the |
@nigeltao
IMO, I'm not sure if there's a demand for 2/4 bit bitmap support. However, there is a demand for 1bit bitmap support. |
Partly maintenance, but partly because it's not obvious how to adapt or extend the encoding API in a backwards compatible way, that doesn't involve changes to the standard library (e.g. its
I'm not denying that 1-bit BMPs are a useful feature. To repeat myself, I'm saying that not every useful feature has to live in the Go standard library or the |
I see. Thank you for your reply. |
Seems like this PR got stuck on the question of writing 1-bit files, but it does implement reading, which is great for our use case. Is it worth merging? Would love 2 and 4 bit support as well but this is a good start. |
I'm OK with that but IIUC it's up to @cbrake to start a PR. |
I'm interested in getting this merged, but it would take me some time to get through all the steps to get set up as a Go contributor (review license CLA, set up accounts, etc) as I'm no longer working on this project and don't have funding to do this work. If anyone else is interested, please feel free to use my patch in any way helpful. |
Hi, I implemented support for 1-bit bmp files in the reader:
cbrake/golang.org-x-image@25481fe
Is there interest merging this (or an improved version)?
The text was updated successfully, but these errors were encountered: