|
Drawing translucent Bitmap. |
coder123
Member #14,305
May 2012
|
Hi, In this way I draw the bitmap: al_draw_bitmap_region(BTNBMP, curFrame, framePos, frameWidth, frameHeight, cx, cy, 0); Using A5. |
Thomas Fjellstrom
Member #476
June 2000
|
I believe you want al_draw_tinted_bitmap_region. ie: al_draw_tinted_bitmap_region(bitmap, al_map_rgba_f(1, 1, 1, 0.5), sx, sy, sw, sh, dx, dy, 0); Will draw the bitmap at 50% translucency. -- |
Mark Oates
Member #1,146
March 2001
|
Thomas Fjellstrom said: ie: al_draw_tinted_bitmap_region(bitmap, al_map_rgba_f(1, 1, 1, 0.5), sx, sy, sw, sh, dx, dy, 0); You should multiply each of the color components by the opacity: float opacity = 0.5; ALLEGRO_COLOR tint = al_map_rgba_f(1*opacity, 1*opacity, 1*opacity, opacity); al_draw_tinted_bitmap_region(bitmap, tint, sx, sy, sw, sh, dx, dy, 0); (interesting fact: "tint" is not the correct term in color theory for this type of color change, but it's what allegro uses.) -- |
Thomas Fjellstrom
Member #476
June 2000
|
Hm, I grabbed that example from the docs. but I think you're right. To use the code I gave, you'd have to disable pre-multiplied alpha. -- |
coder123
Member #14,305
May 2012
|
Thank you. That's what I need.
|
|