Draw rgb information from al_get_pixel with al_draw_text
geograman

Heyho,

can someone show me the most effective way of how to use al_draw_text to draw the rgb information from al_get_pixel.

I tried to do this:

currentPixel = al_get_pixel(image, w, h);
al_unmap_rgb(currentPixel, &r, &g, &b);
al_draw_text(currentFont, al_map_rgb(255, 255, 255), 50, 50, ALLEGRO_ALIGN_LEFT, r);

but al_draw_text wants to have a const char.

Bruce Perry
//Extract the colour values
unsigned char r, g, b;
al_unmap_rgb(currentPixel, &r, &g, &b);

//Use the formatted text function
al_draw_textf(currentFont, al_map_rgb(255, 255, 255), 50, 50, ALLEGRO_ALIGN_LEFT, "(%d, %d, %d)", r, g, b);

...I didn't notice you'd already found al_unmap_rgb when I wrote that :)

geograman

Wow, very straightforward, thanks a lot Bruce Perry! :)

Thread #617143. Printed from Allegro.cc