Skip to content
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

Add preliminary support for word-swap for odd rows #8

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

mkst
Copy link
Contributor

@mkst mkst commented Mar 28, 2023

Opening as draft for comments:

  • Not sure if this is the best place to be making the changes
  • Not 100% sure if the changes work (I'll try do some testing later this week).
  • Not sure if the logic can't be simplified/improved, maybe a better iterator or zip or something to do the swapping.

I also ran the image.py through black which is why its formatted a little different - happy to undo that and recommit separately.

Example swapping a 32-pixel image:

# I4 (8 pixels makes 4 bytes)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] # orig xrange
[8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7] # swapped xrange

# I8 (4 pixels makes 4 bytes):
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
[4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11, 20, 21, 22, 23, 16, 17, 18, 19, 28, 29, 30, 31, 24, 25, 26, 27]

# RGBA16 (2 pixels makes 4 bytes):
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62]
[4, 6, 0, 2, 12, 14, 8, 10, 20, 22, 16, 18, 28, 30, 24, 26, 36, 38, 32, 34, 44, 46, 40, 42, 52, 54, 48, 50, 60, 62, 56, 58]

# RGBA32 (1 pixel makes 4 bytes):
[0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124]
[4, 0, 12, 8, 20, 16, 28, 24, 36, 32, 44, 40, 52, 48, 60, 56, 68, 64, 76, 72, 84, 80, 92, 88, 100, 96, 108, 104, 116, 112, 124, 120]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant