-
-
Notifications
You must be signed in to change notification settings - Fork 660
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
How to get BW image as output - barcode.write() outputs 24 bit (Format24bppRgb) color image #44
Comments
I timed it, one QR code takes approx. 35 msec, and the image is approx 1MB big. With 2000 of them to run, I get 70 seconds runtime. I think that getting BW 1 bit image directly will cut this time a lot. The cloning and changing to B/W image takes 2 msec. |
There is no option available but you can write your own renderer. Take a look at the source code of the BitmapRenderer class. Implement your own BitmapRenderer1bpp, change the line
After that you can use your custom renderer with the BitmapWriter:
|
Great. Thank you! |
I had a need for this as well and the class I developed is at bottom. It does not support Options or text content but otherwise seems to work fine. Suggestions for improvement are welcome. Not thoroughly tested and only tested with QR codes. Usage is:
Too bad there is not native support for monochrome QR because they are vastly smaller and substantially quicker to create. And of course black and white output is usually what's desired, not color. Here's the custom class:
|
How can I get a black and white image from barcode.write(). What I get is 24 bit 1.03MB big full color image.
I convert it to 1bpp with this
But barcodewriter first creates 24bit color 1MB big image, and then I convert it to 1 bit per pixel image which is 43Kb. Is there a parameter where I can set QR code to be just black and white? I have to create 2000 QR codes, and this is just too slow... :(
The text was updated successfully, but these errors were encountered: