Bitfield from a Picture

Hello SDL members,

First my excuse why i write :slight_smile:
I am new to SDL and Game programming.

I want to build in a Collosion Detection in my game. Pixel exact

The bitmask contains only 1 for e.g. WALL and 0 for Water
I have a Surface wich contains only Black and White Pixels
Then i have a Function which read the Pixel information from a given point
and returns the content ( i copied it from a example of this list )
like this

for( i = 0; i<640; i++) {
for( j = 0; j <480; j++ ) {
storage[i][j] = get_pixel( levelraw, i, j );
/* the function get_pixel is at the bottom */

Yo it is the whole background as you can see :slight_smile:

now i have the whole thing in memory so i start to convert 32 Byte from this
array to 4 Byte of my Bitfield I used the ORD schema

/* Convert the Informations into a 4 byte Bitmask */
int m, g, a, h;

for(h=0; h<640; h++ ) {
for(m=0; m<20; m++) {
for(g=0; g<15; g++) {
b = 1;

                       for(a=0; a<32; a++ ) {
                                if( storage[h][a]  == 0 ) {
                                    cstorage[m][g] |= b;
                       b *= 2;

/* Convert the Informations into a Bitmask Ende */

this is the first part that did not work

and if i print the array[640][480]

for( i = 0; i<640; i++) {
for( j = 0; j <480; j++ ) {
printf("%x", storage[i][j]);
the picture looks right but it is rotatet its that my fault or how bitmaps are
saved in memory?

i think thats are all my problems until now

ps: if its relevant in the moment i develop on a windows machine

best regards, simson
-------------- next part --------------
A non-text attachment was scrubbed…
Type: application/x-zip-compressed
Size: 7536 bytes
Desc: not available