al_set_blender - Online Linux Manual PageSection : 3
Updated :
Source : Allegro reference manual
Note :

NAMEal_set_blender − Allegro 5 API

SYNOPSIS #include <allegro5/allegro.h> void al_set_blender(int op, int src, int dst)

DESCRIPTIONSets the function to use for blending for the current thread. Blending means, the source and destination colors are combined in drawing operations. Assume the source color (e.g. color of a rectangle to draw, or pixel of a bitmap to draw) is given as its red/green/blue/alpha components (if the bitmap has no alpha it always is assumed to be fully opaque, so 255 for 8−bit or 1.0 for floating point): s = s.r, s.g, s.b, s.a. And this color is drawn to a destination, which already has a color: d = d.r, d.g, d.b, d.a. The conceptional formula used by Allegro to draw any pixel then depends on the op parameter: • ALLEGRO_ADD  r = d.r * df.r + s.r * sf.r  g = d.g * df.g + s.g * sf.g  b = d.b * df.b + s.b * sf.b  a = d.a * df.a + s.a * sf.a • ALLEGRO_DEST_MINUS_SRC  r = d.r * df.r − s.r * sf.r  g = d.g * df.g − s.g * sf.g  b = d.b * df.b − s.b * sf.b  a = d.a * df.a − s.a * sf.a • ALLEGRO_SRC_MINUS_DEST  r = s.r * sf.r − d.r * df.r  g = s.g * sf.g − d.g * df.g  b = s.b * sf.b − d.b * df.b  a = s.a * sf.a − d.a * df.a Valid values for the factors sf and df passed to this function are as follows, where s is the source color, d the destination color and cc the color set with al_set_blend_color(3) (white by default) • ALLEGRO_ZERO  f = 0, 0, 0, 0 • ALLEGRO_ONE  f = 1, 1, 1, 1 • ALLEGRO_ALPHA  f = s.a, s.a, s.a, s.a • ALLEGRO_INVERSE_ALPHA  f = 1 − s.a, 1 − s.a, 1 − s.a, 1 − s.a • ALLEGRO_SRC_COLOR (since: 5.0.10, 5.1.0)  f = s.r, s.g, s.b, s.a • ALLEGRO_DEST_COLOR (since: 5.0.10, 5.1.8)  f = d.r, d.g, d.b, d.a • ALLEGRO_INVERSE_SRC_COLOR (since: 5.0.10, 5.1.0)  f = 1 − s.r, 1 − s.g, 1 − s.b, 1 − s.a • ALLEGRO_INVERSE_DEST_COLOR (since: 5.0.10, 5.1.8)  f = 1 − d.r, 1 − d.g, 1 − d.b, 1 − d.a • ALLEGRO_CONST_COLOR (since: 5.1.12, not supported on OpenGLES 1.0)  f = cc.r, cc.g, cc.b, cc.a • ALLEGRO_INVERSE_CONST_COLOR (since: 5.1.12, not supported on OpenGLES 1.0)  f = 1 − cc.r, 1 − cc.g, 1 − cc.b, 1 − cc.a Blending examples: So for example, to restore the default of using premultiplied alpha blending, you would use: al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); As formula: r = d.r * (1 − s.a) + s.r * 1 g = d.g * (1 − s.a) + s.g * 1 b = d.b * (1 − s.a) + s.b * 1 a = d.a * (1 − s.a) + s.a * 1 If you are using non−pre−multiplied alpha, you could use al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); Additive blending would be achieved with al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); Copying the source to the destination (including alpha) unmodified al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); Multiplying source and destination components al_set_blender(ALLEGRO_ADD, ALLEGRO_DEST_COLOR, ALLEGRO_ZERO) Tinting the source (like al_draw_tinted_bitmap(3)) al_set_blender(ALLEGRO_ADD, ALLEGRO_CONST_COLOR, ALLEGRO_ONE); al_set_blend_color(al_map_rgb(0, 96, 255)); /* nice Chrysler blue */ Averaging source and destination pixels al_set_blender(ALLEGRO_ADD, ALLEGRO_CONST_COLOR, ALLEGRO_CONST_COLOR); al_set_blend_color(al_map_rgba_f(0.5, 0.5, 0.5, 0.5)); As formula: r = d.r * 0 + s.r * d.r g = d.g * 0 + s.g * d.g b = d.b * 0 + s.b * d.b a = d.a * 0 + s.a * d.a

SEE ALSOal_set_separate_blender(3), al_set_blend_color(3), al_get_blender(3)
0
Johanes Gumabo
Data Size   :   22,813 byte
man-al_set_blender.3Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 239,202
Visitor ID   :     :  
Visitor IP   :   18.119.166.141   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.