-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Image Magic usage #69
Comments
Hi @ironlungx, A commandline tool would be great! I've had plans for making one, but never really started. Feel free to use the same name (if you want), and we'll link to it from the online tool. Regarding the For example: // This sequence of two bytes:
10000000 10110000
// becomes (note the byte order staying the same)
00000001 00001101 In the Javascript (here) it looks like this: function bitswap(b) {
if (settings.bitswap) {
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
}
return b;
} This takes a decimal value, reverses its bits and returns the new (decimal) value. I'm sure you could do this in other ways as well, but bitwise operators are fast and this way both the input and output are a decimal value (no conversion to a string or something similar needed). For clarity, this is what each of the // in:
10110000 // 176
// first bitwise operation, swapping the first and second blocks of four bits
[1011]x[0000] => [0000] [1011]
// second bitwise operation, swapping the first two and last two groups of 2 bits
[00]x[00] [10]x[11] => [00][00] [11][10]
// third bitwise operation, swapping every bit with its neighbor:
[0]x[0] [0]x[0] [1]x[1] [1]x[0] => [0] [0] [0] [0] [1] [1] [0] [1]
// the result is the reverse, from 10110000 to 00001101 |
Hi @ironlungx, did this help solve your problem? |
hi yes it did help! I'm working on it rn 🙂 |
Hi, I've been a long time user of image2cpp and am considering sponsoring it. I am making a script that is similar to your website, it uses image magick to convert images to c arrays. The only thing missing is the 'swap' feature. It would be great if you could point me in the right direction on how to implement it.
p.s. sorry if the issue is irrelevant, i felt that asking you would give me the best answer.
Thanks for taking a look!
The text was updated successfully, but these errors were encountered: