Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to get integers from ALLEGRO_BITMAP

This thread is locked; no one can reply to it. rss feed Print
How to get integers from ALLEGRO_BITMAP
Chris Katko
Member #1,881
January 2002
avatar

An ALLEGRO_COLOR struct is four floats.

So how do I get integers? I'm pretty sure my screen isn't a floating point 24-bit display... it's not likely to be stored in OpenGL as floats.

[edit] To be clear, I mean, without the speed penalty of ALLEGRO converting from NATIVE to FLOAT and back to INTEGER. I just want native.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Polybios
Member #12,293
October 2010

  1. Lock the bitmap with ALLEGRO_PIXEL_FORMAT_ANY and have a look at the ALLEGRO_LOCKED_REGION you get - format will tell you the native format the driver chose, I think it's been ALLEGRO_PIXEL_ABGR_8888 (or with _LE) for me (32 bits)

  2. Read from ALLEGRO_LOCKED_REGION's data pointer, observing pitch and pixel size

  3. Don't forget to unlock and use ALLEGRO_LOCK_READONLY to avoid reuploading when unlocking

Go to: