Reading color of individual pixels in bitmap(allegro)

Started by
3 comments, last by TDragon 18 years, 9 months ago
I'm trying to create a program that will make a mosaic like picture by reading the color of a pixel and surrounding pixels, thereby determining what that area's color should be; then I'd make a new bitmap made up of other bitmaps . So how can i read a pixels color in a bitmap using allegro?
Advertisement
How you do depends on what kind of bitmap you've got. This page should give you details.

Edit: you can also use getpixel(), but that tends to be less efficient than direct memory access.
i looked there but im not sure how read_line can determine the color of a pixel. i think getpixel is actually the thing i wanted though.
And then you can use the get*() functions to check the RGB values of individual pixels ...

Jesus saves ... the rest of you take 2d4 fire damage.

If you can guarantee that it's a memory bitmap (like, calling create_memory_bitmap()), your_bitmap->line[y][x] is the fastest way. Otherwise, you'd need to use some form of getpixel().
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++

This topic is closed to new replies.

Advertisement