Width of a bitmap
Albin Engström

How do i get the width of a bitmap?

is there a handy function for this in allegro or do i have to make one myself?

X-G

... BITMAP *b; b->w

CGamesPlay

BITMAPClick it.

Albin Engström

Thanks ;D,
oh, missed that part of the manual.. will look harder next time.

but what should i do if the bitmap is in a datafile?
(BITMAP*)datafiles::sprites_enemies[1].dat->w
doesn't work :/

23yrold3yrold

Needs more brackets on that one IIRC.
(BITMAP*)(sprites_enemies[1].dat)->w
Something like that; I forget exactly.

CGamesPlay

The dat member is a void*, so it doesn't have a w member. However, the void* is really a BITMAP, so we cast it: (BITMAP*) datafiles::sprites_enemies[1].dat. From there, we take the w member: ((BITMAP*) datafiles::sprites_enemies[1].dat)->w. This is the order of operations, and it is said that the -> binds "tighter" than the (BITMAP*), so we have to use parentheses to switch the order.

Albin Engström

still doesn't work :( "`void*' is not a pointer-to-object type "

CGamesPlay

My post has the right way to do it...

Albin Engström

totally sweet 8-). thanks!

Thread #591555. Printed from Allegro.cc