Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » BITMAP pitch?

This thread is locked; no one can reply to it. rss feed Print
BITMAP pitch?
A J
Member #3,025
December 2002
avatar

how can i check if the pitch is the same as the width.

so there is no padding bytes..

here is what i found on the topic:
http://www.allegro.cc/forums/view_thread.php?_id=364706

any code snippet would be nice ;)

___________________________
The more you talk, the more AJ is right. - ML

23yrold3yrold
Member #1,134
March 2001
avatar

... "pitch"?

If this is the file format you're talking about, padding just forces the pixel rows to be a multiple of 4. So if the width isn't a multiple of 4 in 8-bit, if it's odd in 16-bit, or the width * 3 isn't a multiple of 4 in 24-bit, then there's padding. 32-bit suffers no problems. :)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

A J
Member #3,025
December 2002
avatar

can i test this somehow ?

maybe a code snippet.

here is my effort, which gives incorrect results

uint32_t* p1 = &((uint32_t*)map->line[1])[0];
uint32_t* p2 = (uint32_t*)map->dat;
p2 += (map->w * 4);
if ( p1 != p2 )
  padded !

___________________________
The more you talk, the more AJ is right. - ML

Krzysztof Kluczek
Member #4,191
January 2004
avatar

p2 += map->w;
should work better. Adding integer to pointer takes care about pointed object's size itself. :)

EDIT: Made above statement more understandable. ;)

A J
Member #3,025
December 2002
avatar

tried that, still doesn't work.

___________________________
The more you talk, the more AJ is right. - ML

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Then maybe:

char *p1 = (char *)map->line[0];
char *p2 = (char *)map->line[1];
p1 += 4*map->w;
if(p1==p2)
 do_something();

or if this still doesn't work, you could try casting pointer to int. :)

A J
Member #3,025
December 2002
avatar

uint32_t* p1 = &((uint32_t*)map->line[1])[0];
uint32_t* p2 = &((uint32_t*)map->line[0])[map->w];

when i tested them, they were 32 bytes apart.

___________________________
The more you talk, the more AJ is right. - ML

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Are you sure, that:
1) there are really no padding bytes?
2) bitmap is in 32-bit format?

A J
Member #3,025
December 2002
avatar

i have decided to do it differently.

thank you anyway.

___________________________
The more you talk, the more AJ is right. - ML

Go to: