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
Speedup drawing of reversed elements #64
Conversation
InvertDraw calls are very slow, so this is an attempt to reduce them as much as possible by drawing only one inverted canvas for all reversed elements and even this one only if needed.
Very cool. |
In theory there is one condition where the result would be "wrong". That would be reversing an already reversed pixel. But the calculation time of over 10s is simply not acceptable. Maybe there is a faster function available for combining the bitmaps. |
Is it possible to provide your sample label for my testing, if no privacy issue? At the moment please leave this as draft. |
I have already thought about this topic. But I haven't got around to optimizing the logic yet. The time consuming part is the verification of each pixel. The bigger the label is, the longer it takes. A sensible solution would therefore be to determine where in the last step was drawn and to match only this area I think with this solution this step could be significantly accelerated. |
I did all this for EPL once. Back then I decided to just paint with reversed colors. I directly drew to a windows form and speed was essential (and I needed texts to be selectable, highlightable and to support text copy). There was no noticable delay, and now we need to switch from epl to zpl. With a 10 second delay nobody would want to use that app anymore. So maybe a 'draft' or 'preview' rendering mode could help ? Btw. my final step will now be adding datamatrix support. But I guess I will open a separate issue for that. Those 2D barcodes are also part of every GLS label - and probably any other real life shipping label. |
What about using XOR SKBlendMode for reversed drawing in the first place ? |
I'll check that I haven't had time to deal with this module yet. |
@M-Mommsen Can you print our test label on an original Zebra Printer? |
@M-Mommsen i have create a test script with the
But white to white should be black
|
That's great!
Why ? White = nothing is painted or reversed - so white to white should stay white! Only black and white (or white and black) become black! Could you try: One other doc says: |
I don't know where the file is located :-( ... |
Hmm - documentation is different. So is it a printer quirk ? We could simulate this behaviour by ignoring the W parameter when printing reversed. ^XA ^FO10,10 ^FR ^FR ^XZ Yes - just tested it with the same result! So the zebra is simply ignoring the color in reverse mode! |
@M-Mommsen |
The rendering now takes ~0.6s, which is still not great, but so much better than the 10s plus before! |
InvertDraw calls are very slow, so this is an attempt to reduce them as much as possible by drawing only one inverted canvas for all reversed elements and even this one only if needed.
In my tests with a GLS label, the calculation time went from ~12s to 1s !