Reading color of individual pixels in bitmap(allegro)
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?
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.
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 ...
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().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement