-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adding a fancy Bitmap blit function with rotation, scaling and clipping of both source and destination bitmaps #4170
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
Conversation
|
nifty! thanks for the contribution! |
I'm ok calling it fancy blit.
Whatever is consistent with existing APIs (I can't remember.) One reason to avoid tuples is it forces an object creation.
Either way. It'll probably be a bit cleaner in the long run.
Sure, that'd make sure the implementation is the same.
I think it's very cool and worth having in CP. I don't think adding it to Bitmap is good though because it increases the size of the baseline Bitmap class. Instead we could have a |
|
Thanks for the feedback, I added a few functions to reduce the repetition, saved a little space, but still about 2k larger than the previous. Makes sense to put it into a different module, since I can envision other bitmap manipulation functions (I'm already thinking about a blit version with color re-mapping options). How about a name like like Next question, is how do I break it into a separate chunk? |
|
I like |
|
The "rotate-scale" transform is usually called "rotozoom" in the demoscene — just in case you needed a shorter name. |
|
@tannewt I see the basic idea of what you are talking about for adding a new directory for bitmap_tools in Right now I don't forsee any port-specific code, so does it need anything in common-hal for each port? How do I tell the build system to include the new files when I build a given port? Thanks for you guidance! |
Nope! You can just put it in
Take a look in |
adafruit_bus_device was similarly python code moved to the core so that may help you see what for something similar. Feel free to ping me on discord too as someone who just recently did this from a newbie point of view. |
|
I'm going to close this PR and start a cleaner one with the new module addition. |
|
This PR is superceded by #4256 |
A few questions for feedback:
Bitmap.blitfancy, maybeblit_rotate_scale?ox,oyandpx,pybe sent as(x,y)tuples?constrain_clip_boundaryfunction to constrain and arrange the clip coordinates, since this code is duplicated? (Save space)This version added about 2kB to a build on the PyPortal (atmel-samd). Not sure if it's worth the added space.
Benchmark
Performance of this core function is ~50x faster at blitting than running the same algorithm in Python (tested on PyPortal).
Here's the Python code for comparison: