RotateBitmap function

I’m currently trying to code a small game, which is rather hard with my small programming experience.
At the moment I’m able to do some small things, but to do what I want I need a function to rotate a Bitmap.
So I started searching the Internet.
(The stepless one, so you can choose any angle)
This seems like a smart way to do so, but I’m not even able to convert those Hex Bitmaps to Binary, which seems like an import step for me.
Maybe I’m not the only one…
I think that’s a function the Library is still missing.
(Mirror too :P)

But maybe someone can give me a little help here

This doesn’t make sense. The ‘hex bitmaps’ are stored as binary. Hexadecimal, binary and decimal are all just different ways of representing the same numbers. For example, 255 in decimal is equivalent to FF in hexadecimal, 377 in octal and 11111111 in binary. There’s a good explanation of that here.

Out of interest, why do you want to rotate a bitmap?
There might be a simpler way to do things depending on what it is you’re trying to rotate and what angles you want to rotate by.

I’m not 100% sure, but I think when working with Gamebuino I worked with binary/boolean bitmaps (Arrays of 1/0), so the picture is easy changable in the code.
{1, 0, 1,
0, 1, 0,
1, 0, 1}
I think it makes the code bigger than it needs to be, but I could imagine this would make the rotating process a bit easier.

I want to make figures seesaw(?).

I hope that makes some sense.

It does make things easier, but it uses 8 times the space it needs to.
By storing an image as an array of bools, you are effectively using 8 bits per pixel when a pixel can only have 2 values: black or white. The way that Arduboy does it uses 1 bit per pixel, thus fitting the values for 8 pixels into 1 byte.

To access the individual bits you’d need to learn how to do bit shifting. There’s also this wikipedia article about bit shifting. I don’t know if it’s a good article weil mein Deutsh nicht so gut ist.

If the images can be made from lines and basic shapes, you could take the points that make up the image and rotate them.

To rotate a whole image on a device like the arduboy would be much harder. If you don’t have many images it would be easier to make hand drawn bitmap rotations, even if it means using more memory.

1 Like

I thought of Bit operations myself, but the real problem is those “packages” that come with the hexadecimal way of writing numbers. The way they are listed in the array and the image are way to confusing for me, especially if the picture height or width are not divisible by 8.
But I think I will go with working with lines and circles, like you said.

It’s not hard to convert between hexadecimal and binary.
You can write programs to do it for you (most languages have a way of converting between the two) or you could manually rewrite them as binary if you don’t quite understand hex.

This table might make things a bit clearer:

Decimal → Hex → Binary
0 → 0 → 0000
1 → 1 → 0001
2 → 2 → 0010
3 → 3 → 0011
4 → 4 → 0100
5 → 5 → 0101

9 → 9 → 1001
10 → A → 1010
11 → B → 1011
12 → C → 1100
13 → D → 1101
14 → E → 1110
15 → F → 1111

There’s a nice image somewhere on the forums that explains how it works, but I can’t find it.
Basically instead of the bits of a byte being horizontal lines, they’re vertical.

So take this creeper face for example.

That would be represented as:

0b00000000, // Far left column
0b00000110, // 2nd column
0b00000000, // Far right column

If you turn your head 90 degrees clockwise, you can just about make out the creeper face.

Another example here.

This is a problem. The only way to get around that is by padding the image.
On old consoles, images were always divisible by 4 or 8 precisely because it makes it easier for the hardware to work with. Modern computers don’t have this limitation, or at least have ways of getting around it.

This is definately the easiest method. In fact the guy who I program with somtimes recently worked on making a shape-based version of the Kestral (a spaceship) from the game FTL, and he made a nice demo that proved how much easier it is to use vector graphics with the Arduboy. If you like it, tell him to keep working on it