how do i store rgb values of a single pixel of an image to a text file or config file(pls)?
Well, there's two parts to that. First, you need to obtain the pixel color data from the image, and next, write it to the file.
Get the pixel color of an image.
To obtain the color from an image, you'll use al_get_pixel to grab individual color components at a coordinate.
Note that you could also get the alpha color value if you use al_map_rgba, or you can get the values as floats rather than unsigned chars with the al_map_rgba_f, and al_map_rgb_f variations.
Writing color data to a file
If you're using C++, writing data to a file is relatively simple.
color, std::string filename="my_color_file.txt")
7 unsigned char
8 unsigned char
9 unsigned char
11 // get the color
b); // will "fill" r, g, and b with that color's value.
15 // write the values to a file
filename); // ofstream is an "output file" stream
r << " " <<
g << " " <<
21 return true;
There are a lot of optimizations you could make with these functions - for example, if you wanted to store multiple color values to a file you might fold get_image_color_at() and write_color_to_file() together (and possibly add a loop). Ideally, you should only open an ALLEGRO_BITMAP once.