I'm looking for a way to quickly rotate the bits in a byte array without massive for loops that gets and sets each bit from old to new position. In this particular circumstance I need to rotate by 90 degrees clockwise. So for instance if I have:
unsigned char array[8] = {
0b11110000,
0b10000000,
0b10000000,
0b10000000,
0b00000000,
0b00000000,
0b00000000,
0b00000001
};
I need to get:
unsigned char array[8] = {
0b00001111,
0b00000001,
0b00000001,
0b00000001,
0b00000000,
0b00000000,
0b00000000,
0b10000000
};
Looking for the most efficient way possible to do this ... but it may not always be an 8x8 grid of bits. Will always be power of 2 dimension though (if that helps!)