<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><head><title> Allegro Manual: Transparency and patterned drawing </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <link rel="stylesheet" title="Default" type="text/css" href="allegro.css"></head><body bgcolor=white text=black link="#0000ee" alink="#ff0000" vlink="#551a8b"> <h1><a name="Transparency and patterned drawing">Transparency and patterned drawing</a></h1> <ul> <li><a href="#color_map">color_map</a> — Global pointer to the color mapping table. <li><a href="#create_blender_table">create_blender_table</a> — Emulates truecolor blender effects in paletted modes. <li><a href="#create_color_table">create_color_table</a> — Fills a color mapping table for customised effects. <li><a href="#create_light_table">create_light_table</a> — Fills a color mapping table for lighting effects. <li><a href="#create_trans_table">create_trans_table</a> — Fills a color mapping table for translucency effects. <li><a href="#drawing_mode">drawing_mode</a> — Sets the graphics drawing mode. <li><a href="#set_add_blender">set_add_blender</a> — Enables an additive blender mode. <li><a href="#set_alpha_blender">set_alpha_blender</a> — Enables a special alpha-channel blending mode. <li><a href="#set_blender_mode">set_blender_mode</a> — Specifies a custom set of truecolor blender routines. <li><a href="#set_blender_mode_ex">set_blender_mode_ex</a> — An even more complex version of set_blender_mode(). <li><a href="#set_burn_blender">set_burn_blender</a> — Enables a burn blender mode. <li><a href="#set_color_blender">set_color_blender</a> — Enables a color blender mode. <li><a href="#set_difference_blender">set_difference_blender</a> — Enables a difference blender mode. <li><a href="#set_dissolve_blender">set_dissolve_blender</a> — Enables a dissolve blender mode. <li><a href="#set_dodge_blender">set_dodge_blender</a> — Enables a dodge blender mode. <li><a href="#set_hue_blender">set_hue_blender</a> — Enables a hue blender mode. <li><a href="#set_invert_blender">set_invert_blender</a> — Enables an invert blender mode. <li><a href="#set_luminance_blender">set_luminance_blender</a> — Enables a luminance blender mode. <li><a href="#set_multiply_blender">set_multiply_blender</a> — Enables a multiply blender mode. <li><a href="#set_saturation_blender">set_saturation_blender</a> — Enables a saturation blender mode. <li><a href="#set_screen_blender">set_screen_blender</a> — Enables a screen blender mode. <li><a href="#set_trans_blender">set_trans_blender</a> — Enables a truecolor blender. <li><a href="#set_write_alpha_blender">set_write_alpha_blender</a> — Enables the special alpha-channel editing mode. <li><a href="#solid_mode">solid_mode</a> — Shortcut for selecting solid drawing mode. <li><a href="#xor_mode">xor_mode</a> — Shortcut for toggling xor drawing mode on and off. </ul> <p><br> <div class="al-api"><b>void <a name="drawing_mode">drawing_mode</a>(int mode, <a class="autotype" href="alleg001.html#BITMAP" title="Stores the contents of a bitmap.">BITMAP</a> *pattern, int x_anchor, int y_anchor);</b></div><br> Sets the graphics drawing mode. This only affects the geometric routines like putpixel, lines, rectangles, circles, polygons, floodfill, etc, not the text output, blitting, or sprite drawing functions. The mode should be one of the following constants: <blockquote class="text"><pre> DRAW_MODE_SOLID - the default, solid color drawing DRAW_MODE_XOR - exclusive-or drawing DRAW_MODE_COPY_PATTERN - multicolored pattern fill DRAW_MODE_SOLID_PATTERN - single color pattern fill DRAW_MODE_MASKED_PATTERN - masked pattern fill DRAW_MODE_TRANS - translucent color blending </pre></blockquote> In DRAW_MODE_SOLID, pixels of the bitmap being drawn onto are simply replaced by those produced by the drawing function. <p> In DRAW_MODE_XOR, pixels are written to the bitmap with an exclusive-or operation rather than a simple copy, so drawing the same shape twice will erase it. Because it involves reading as well as writing the bitmap memory, xor drawing is a lot slower than the normal replace mode. <p> With the patterned modes, you provide a pattern bitmap which is tiled across the surface of the shape. Allegro stores a pointer to this bitmap rather than copying it, so you must not destroy the bitmap while it is still selected as the pattern. The width and height of the pattern must be powers of two, but they can be different, eg. a 64x16 pattern is fine, but a 17x3 one is not. The pattern is tiled in a grid starting at point (x_anchor, y_anchor). Normally you should just pass zero for these values, which lets you draw several adjacent shapes and have the patterns meet up exactly along the shared edges. Zero alignment may look peculiar if you are moving a patterned shape around the screen, however, because the shape will move but the pattern alignment will not, so in some situations you may wish to alter the anchor position. <p> When you select DRAW_MODE_COPY_PATTERN, pixels are simply copied from the pattern bitmap onto the destination bitmap. This allows the use of multicolored patterns, and means that the color you pass to the drawing routine is ignored. This is the fastest of the patterned modes. <p> In DRAW_MODE_SOLID_PATTERN, each pixel in the pattern bitmap is compared with the mask color, which is zero in 256-color modes or bright pink for truecolor data (maximum red and blue, zero green). If the pattern pixel is solid, a pixel of the color you passed to the drawing routine is written to the destination bitmap, otherwise a zero is written. The pattern is thus treated as a monochrome bitmask, which lets you use the same pattern to draw different shapes in different colors, but prevents the use of multicolored patterns. <p> DRAW_MODE_MASKED_PATTERN is almost the same as DRAW_MODE_SOLID_PATTERN, but the masked pixels are skipped rather than being written as zeros, so the background shows through the gaps. <p> In DRAW_MODE_TRANS, the global color_map table or truecolor blender functions are used to overlay pixels on top of the existing image. This must only be used after you have set up the color mapping table (for 256 color modes) or blender functions (for truecolor modes). Because it involves reading as well as writing the bitmap memory, translucent drawing is very slow if you draw directly to video RAM, so wherever possible you should use a memory bitmap instead. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#xor_mode" title="Shortcut for toggling xor drawing mode on and off.">xor_mode</a>, <a class="xref" href="#solid_mode" title="Shortcut for selecting solid drawing mode.">solid_mode</a>, <a class="xref" href="#color_map" title="Global pointer to the color mapping table.">color_map</a>, <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#exalpha" title="Creating and using 32 bit RGBA sprites.">exalpha</a>, <a class="eref" href="alleg045.html#excolmap" title="Creating graphical effects with color mapping tables.">excolmap</a>, <a class="eref" href="alleg045.html#exjoy" title="Detecting, calibrating and using joystick input.">exjoy</a>, <a class="eref" href="alleg045.html#expat" title="Using patterned drawing modes and sub-bitmaps.">expat</a>, <a class="eref" href="alleg045.html#extrans" title="Lighting and translucency effects.">extrans</a>.</blockquote> <div class="al-api"><b>void <a name="xor_mode">xor_mode</a>(int on);</b></div><br> This is a shortcut for toggling xor drawing mode on and off. Calling xor_mode(TRUE) is equivalent to drawing_mode(DRAW_MODE_XOR, NULL, 0, 0). Calling xor_mode(FALSE) is equivalent to drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0). <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#exspline" title="Constructing smooth movement paths from spline curves.">exspline</a>, <a class="eref" href="alleg045.html#exupdate" title="Supporting different screen update methods in a single program.">exupdate</a>.</blockquote> <div class="al-api"><b>void <a name="solid_mode">solid_mode</a>();</b></div><br> This is a shortcut for selecting solid drawing mode. It is equivalent to calling drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0). <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#exalpha" title="Creating and using 32 bit RGBA sprites.">exalpha</a>, <a class="eref" href="alleg045.html#expat" title="Using patterned drawing modes and sub-bitmaps.">expat</a>.</blockquote> <br><center><h2><a name="256-color transparency">256-color transparency</a></h2></center><p> In paletted video modes, translucency and lighting are implemented with a 64k lookup table, which contains the result of combining any two colors c1 and c2. You must set up this table before you use any of the translucency or lighting routines. Depending on how you construct the table, a range of different effects are possible. For example, translucency can be implemented by using a color halfway between c1 and c2 as the result of the combination. Lighting is achieved by treating one of the colors as a light level (0-255) rather than a color, and setting up the table appropriately. A range of specialised effects are possible, for instance replacing any color with any other color and making individual source or destination colors completely solid or invisible. Color mapping tables can be precalculated with the colormap utility, or generated at runtime. Read chapter "Structures and types defined by Allegro" for an internal description of the COLOR_MAP structure. <p><br> <div class="al-api"><b>extern <a class="autotype" href="alleg001.html#COLOR_MAP" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> *<a name="color_map">color_map</a>;</b></div><br> Global pointer to the color mapping table. You must allocate your own COLOR_MAP either statically or dynamically and set color_map to it before using any translucent or lit drawing functions in a 256-color video mode! Example: <blockquote class="code"><pre> <a href="#color_map" class="autotype" title="Global pointer to the color mapping table.">color_map</a> = malloc(sizeof(<a href="alleg001.html#COLOR_MAP" class="autotype" title="Stores a color map to accelerate drawing.">COLOR_MAP</a>)); if (!<a href="#color_map" class="autotype" title="Global pointer to the color mapping table.">color_map</a>) abort_on_error("Not enough memory for color map!");</pre></blockquote> <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#create_color_table" title="Fills a color mapping table for customised effects.">create_color_table</a>, <a class="xref" href="#create_light_table" title="Fills a color mapping table for lighting effects.">create_light_table</a>, <a class="xref" href="#create_trans_table" title="Fills a color mapping table for translucency effects.">create_trans_table</a>, <a class="xref" href="#create_blender_table" title="Emulates truecolor blender effects in paletted modes.">create_blender_table</a>, <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg014.html#draw_lit_sprite" title="Draws a sprite tinted with a specific color.">draw_lit_sprite</a>, <a class="xref" href="alleg014.html#draw_gouraud_sprite" title="Draws a sprite with gouraud shading.">draw_gouraud_sprite</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#ex3d" title="3d 'bouncy cubes' demo.">ex3d</a>, <a class="eref" href="alleg045.html#excolmap" title="Creating graphical effects with color mapping tables.">excolmap</a>, <a class="eref" href="alleg045.html#exlights" title="One way to do colored lighting effects in a hicolor video mode.">exlights</a>, <a class="eref" href="alleg045.html#exshade" title="Gouraud shaded sprites.">exshade</a>, <a class="eref" href="alleg045.html#extrans" title="Lighting and translucency effects.">extrans</a>.</blockquote> <div class="al-api"><b>void <a name="create_trans_table">create_trans_table</a>(<a class="autotype" href="alleg001.html#COLOR_MAP" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> *table, const <a class="autotype" href="alleg001.html#PALETTE" title="Stores palette information.">PALETTE</a> pal, int r, g, b, void (*callback)(int pos));</b></div><br> Fills the specified color mapping table with lookup data for doing translucency effects with the specified palette. When combining the colors c1 and c2 with this table, the result will be a color somewhere between the two. The r, g, and b parameters specify the solidity of each color component, ranging from 0 (totally transparent) to 255 (totally solid). For 50% solidity, pass 128. <p> This function treats source color #0 as a special case, leaving the destination unchanged whenever a zero source pixel is encountered, so that masked sprites will draw correctly. This function will take advantage of the global rgb_map variable to speed up color conversions. If the callback function is not NULL, it will be called 256 times during the calculation, allowing you to display a progress indicator. Example: <blockquote class="code"><pre> <a href="alleg001.html#COLOR_MAP" class="autotype" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> trans_table; ... /* Build a color lookup table for translucent drawing. */ <a href="#create_trans_table" class="autotype" title="Fills a color mapping table for translucency effects.">create_trans_table</a>(&trans_table, pal, 128, 128, 128, NULL);</pre></blockquote> <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#color_map" title="Global pointer to the color mapping table.">color_map</a>, <a class="xref" href="#create_light_table" title="Fills a color mapping table for lighting effects.">create_light_table</a>, <a class="xref" href="#create_color_table" title="Fills a color mapping table for customised effects.">create_color_table</a>, <a class="xref" href="#create_blender_table" title="Emulates truecolor blender effects in paletted modes.">create_blender_table</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg014.html#draw_lit_sprite" title="Draws a sprite tinted with a specific color.">draw_lit_sprite</a>, <a class="xref" href="alleg014.html#draw_gouraud_sprite" title="Draws a sprite with gouraud shading.">draw_gouraud_sprite</a>, <a class="xref" href="alleg021.html#rgb_map" title="Look up table to speed up reducing RGB values to palette colors.">rgb_map</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#ex3d" title="3d 'bouncy cubes' demo.">ex3d</a>, <a class="eref" href="alleg045.html#extrans" title="Lighting and translucency effects.">extrans</a>.</blockquote> <div class="al-api"><b>void <a name="create_light_table">create_light_table</a>(<a class="autotype" href="alleg001.html#COLOR_MAP" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> *table, const <a class="autotype" href="alleg001.html#PALETTE" title="Stores palette information.">PALETTE</a> pal, int r, g, b, void (*callback)(int pos));</b></div><br> Fills the specified color mapping table with lookup data for doing lighting effects with the specified palette. When combining the colors c1 and c2 with this table, c1 is treated as a light level from 0-255. At light level 255 the table will output color c2 unchanged, at light level 0 it will output the r, g, b value you specify to this function, and at intermediate light levels it will output a color somewhere between the two extremes. The r, g, and b values are in the range 0-63. <p> This function will take advantage of the global rgb_ap variable to speed up color conversions. If the callback function is not NULL, it will be called 256 times during the calculation, allowing you to display a progress indicator. Example: <blockquote class="code"><pre> <a href="alleg001.html#COLOR_MAP" class="autotype" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> light_table; ... /* Build a color lookup table for lighting effects. */ <a href="#create_light_table" class="autotype" title="Fills a color mapping table for lighting effects.">create_light_table</a>(&light_table, pal, 0, 0, 0, NULL);</pre></blockquote> <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#color_map" title="Global pointer to the color mapping table.">color_map</a>, <a class="xref" href="#create_trans_table" title="Fills a color mapping table for translucency effects.">create_trans_table</a>, <a class="xref" href="#create_color_table" title="Fills a color mapping table for customised effects.">create_color_table</a>, <a class="xref" href="#create_blender_table" title="Emulates truecolor blender effects in paletted modes.">create_blender_table</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg014.html#draw_lit_sprite" title="Draws a sprite tinted with a specific color.">draw_lit_sprite</a>, <a class="xref" href="alleg014.html#draw_gouraud_sprite" title="Draws a sprite with gouraud shading.">draw_gouraud_sprite</a>, <a class="xref" href="alleg021.html#rgb_map" title="Look up table to speed up reducing RGB values to palette colors.">rgb_map</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#ex3d" title="3d 'bouncy cubes' demo.">ex3d</a>, <a class="eref" href="alleg045.html#exshade" title="Gouraud shaded sprites.">exshade</a>, <a class="eref" href="alleg045.html#extrans" title="Lighting and translucency effects.">extrans</a>.</blockquote> <div class="al-api"><b>void <a name="create_color_table">create_color_table</a>(<a class="autotype" href="alleg001.html#COLOR_MAP" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> *table, const <a class="autotype" href="alleg001.html#PALETTE" title="Stores palette information.">PALETTE</a> pal, void (*blend)(<a class="autotype" href="alleg001.html#PALETTE" title="Stores palette information.">PALETTE</a> pal, int x, int y, <a class="autotype" href="alleg001.html#RGB" title="Single palette entry.">RGB</a> *rgb), void (*callback)(int pos));</b></div><br> Fills the specified color mapping table with lookup data for doing customised effects with the specified palette, calling the blend function to determine the results of each color combination. <p> Your blend routine will be passed a pointer to the palette and the two indices of the colors which are to be combined, and should fill in the RGB structure with the desired result in 0-63 format. Allegro will then search the palette for the closest match to the RGB color that you requested, so it doesn't matter if the palette has no exact match for this color. <p> If the callback function is not NULL, it will be called 256 times during the calculation, allowing you to display a progress indicator. Example: <blockquote class="code"><pre> <a href="alleg001.html#COLOR_MAP" class="autotype" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> greyscale_table; ... void return_grey_color(const <a href="alleg001.html#PALETTE" class="autotype" title="Stores palette information.">PALETTE</a> pal, int x, int y, <a href="alleg001.html#RGB" class="autotype" title="Single palette entry.">RGB</a> *rgb) { ... } ... /* Build a color lookup table for greyscale effect. */ <a href="#create_color_table" class="autotype" title="Fills a color mapping table for customised effects.">create_color_table</a>(&greyscale_table, pal, return_grey_color, NULL);</pre></blockquote> <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#color_map" title="Global pointer to the color mapping table.">color_map</a>, <a class="xref" href="#create_light_table" title="Fills a color mapping table for lighting effects.">create_light_table</a>, <a class="xref" href="#create_trans_table" title="Fills a color mapping table for translucency effects.">create_trans_table</a>, <a class="xref" href="#create_blender_table" title="Emulates truecolor blender effects in paletted modes.">create_blender_table</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg014.html#draw_lit_sprite" title="Draws a sprite tinted with a specific color.">draw_lit_sprite</a>, <a class="xref" href="alleg014.html#draw_gouraud_sprite" title="Draws a sprite with gouraud shading.">draw_gouraud_sprite</a>, <a class="xref" href="alleg021.html#rgb_map" title="Look up table to speed up reducing RGB values to palette colors.">rgb_map</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#excolmap" title="Creating graphical effects with color mapping tables.">excolmap</a>.</blockquote> <div class="al-api"><b>void <a name="create_blender_table">create_blender_table</a>(<a class="autotype" href="alleg001.html#COLOR_MAP" title="Stores a color map to accelerate drawing.">COLOR_MAP</a> *table, const <a class="autotype" href="alleg001.html#PALETTE" title="Stores palette information.">PALETTE</a> pal, void (*callback)(int pos));</b></div><br> Fills the specified color mapping table with lookup data for doing a paletted equivalent of whatever truecolor blender mode is currently selected. After calling set_trans_blender(), set_blender_mode(), or any of the other truecolor blender mode routines, you can use this function to create an 8-bit mapping table that will have the same results as whatever 24-bit blending mode you have enabled. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#color_map" title="Global pointer to the color mapping table.">color_map</a>, <a class="xref" href="#create_light_table" title="Fills a color mapping table for lighting effects.">create_light_table</a>, <a class="xref" href="#create_trans_table" title="Fills a color mapping table for translucency effects.">create_trans_table</a>, <a class="xref" href="#create_color_table" title="Fills a color mapping table for customised effects.">create_color_table</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg014.html#draw_lit_sprite" title="Draws a sprite tinted with a specific color.">draw_lit_sprite</a>, <a class="xref" href="alleg014.html#draw_gouraud_sprite" title="Draws a sprite with gouraud shading.">draw_gouraud_sprite</a>, <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#set_blender_mode" title="Specifies a custom set of truecolor blender routines.">set_blender_mode</a>.</blockquote> <br><center><h2><a name="Truecolor transparency">Truecolor transparency</a></h2></center><p> In truecolor video modes, translucency and lighting are implemented by a blender function of the form: <blockquote class="code"><pre> unsigned long (*BLENDER_FUNC)(unsigned long x, y, n);</pre></blockquote> <p> For each pixel to be drawn, this routine is passed two color parameters x and y, decomposes them into their red, green and blue components, combines them according to some mathematical transformation involving the interpolation factor n, and then merges the result back into a single return color value, which will be used to draw the pixel onto the destination bitmap. <p> The parameter x represents the blending modifier color and the parameter y represents the base color to be modified. The interpolation factor n is in the range [0-255] and controls the solidity of the blending. <p> When a translucent drawing function is used, x is the color of the source, y is the color of the bitmap being drawn onto and n is the alpha level that was passed to the function that sets the blending mode (the RGB triplet that was passed to this function is not taken into account). <p> When a lit sprite drawing function is used, x is the color represented by the RGB triplet that was passed to the function that sets the blending mode (the alpha level that was passed to this function is not taken into account), y is the color of the sprite and n is the alpha level that was passed to the drawing function itself. <p> Since these routines may be used from various different color depths, there are three such callbacks, one for use with 15-bit 5.5.5 pixels, one for 16 bit 5.6.5 pixels, and one for 24-bit 8.8.8 pixels (this can be shared between the 24 and 32-bit code since the bit packing is the same). <p><br> <div class="al-api"><b>void <a name="set_trans_blender">set_trans_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a linear interpolator blender mode for combining translucent or lit truecolor pixels. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_blender_mode" title="Specifies a custom set of truecolor blender routines.">set_blender_mode</a>, <a class="xref" href="#set_alpha_blender" title="Enables a special alpha-channel blending mode.">set_alpha_blender</a>, <a class="xref" href="#set_write_alpha_blender" title="Enables the special alpha-channel editing mode.">set_write_alpha_blender</a>, <a class="xref" href="#color_map" title="Global pointer to the color mapping table.">color_map</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg014.html#draw_lit_sprite" title="Draws a sprite tinted with a specific color.">draw_lit_sprite</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>, <a class="xref" href="#set_add_blender" title="Enables an additive blender mode.">set_add_blender</a>, <a class="xref" href="#set_burn_blender" title="Enables a burn blender mode.">set_burn_blender</a>, <a class="xref" href="#set_color_blender" title="Enables a color blender mode.">set_color_blender</a>, <a class="xref" href="#set_difference_blender" title="Enables a difference blender mode.">set_difference_blender</a>, <a class="xref" href="#set_dissolve_blender" title="Enables a dissolve blender mode.">set_dissolve_blender</a>, <a class="xref" href="#set_dodge_blender" title="Enables a dodge blender mode.">set_dodge_blender</a>, <a class="xref" href="#set_hue_blender" title="Enables a hue blender mode.">set_hue_blender</a>, <a class="xref" href="#set_invert_blender" title="Enables an invert blender mode.">set_invert_blender</a>, <a class="xref" href="#set_luminance_blender" title="Enables a luminance blender mode.">set_luminance_blender</a>, <a class="xref" href="#set_multiply_blender" title="Enables a multiply blender mode.">set_multiply_blender</a>, <a class="xref" href="#set_saturation_blender" title="Enables a saturation blender mode.">set_saturation_blender</a>, <a class="xref" href="#set_screen_blender" title="Enables a screen blender mode.">set_screen_blender</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#ex3d" title="3d 'bouncy cubes' demo.">ex3d</a>, <a class="eref" href="alleg045.html#exblend" title="Using translucency in truecolor modes.">exblend</a>, <a class="eref" href="alleg045.html#exrotscl" title="Demonstrates rotate_scaled_sprite functions.">exrotscl</a>, <a class="eref" href="alleg045.html#exshade" title="Gouraud shaded sprites.">exshade</a>, <a class="eref" href="alleg045.html#extrans" title="Lighting and translucency effects.">extrans</a>, <a class="eref" href="alleg045.html#extrans2" title="Drawing flipped, translucent and tinted sprites.">extrans2</a>, <a class="eref" href="alleg045.html#exxfade" title="Truecolor image loading and fades.">exxfade</a>.</blockquote> <div class="al-api"><b>void <a name="set_alpha_blender">set_alpha_blender</a>();</b></div><br> Enables the special alpha-channel blending mode, which is used for drawing 32-bit RGBA sprites. After calling this function, you can use draw_trans_sprite() or draw_trans_rle_sprite() to draw a 32-bit source image onto any hicolor or truecolor destination. The alpha values will be taken directly from the source graphic, so you can vary the solidity of each part of the image. You can't use any of the normal translucency functions while this mode is active, though, so you should reset to one of the normal blender modes (eg. set_trans_blender()) before drawing anything other than 32-bit RGBA sprites. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg015.html#draw_trans_rle_sprite" title="Draws a translucent RLE sprite.">draw_trans_rle_sprite</a>, <a class="xref" href="#set_write_alpha_blender" title="Enables the special alpha-channel editing mode.">set_write_alpha_blender</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#exalpha" title="Creating and using 32 bit RGBA sprites.">exalpha</a>, <a class="eref" href="alleg045.html#exrotscl" title="Demonstrates rotate_scaled_sprite functions.">exrotscl</a>, <a class="eref" href="alleg045.html#extrans" title="Lighting and translucency effects.">extrans</a>.</blockquote> <div class="al-api"><b>void <a name="set_write_alpha_blender">set_write_alpha_blender</a>();</b></div><br> Enables the special alpha-channel editing mode, which is used for drawing alpha channels over the top of an existing 32-bit RGB sprite, to turn it into an RGBA format image. After calling this function, you can set the drawing mode to DRAW_MODE_TRANS and then write draw color values (0-255) onto a 32-bit image. This will leave the color values unchanged, but alter the alpha to whatever values you are writing. After enabling this mode you can also use draw_trans_sprite() to superimpose an 8-bit alpha mask over the top of an existing 32-bit sprite. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_alpha_blender" title="Enables a special alpha-channel blending mode.">set_alpha_blender</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#exalpha" title="Creating and using 32 bit RGBA sprites.">exalpha</a>, <a class="eref" href="alleg045.html#extrans" title="Lighting and translucency effects.">extrans</a>.</blockquote> <div class="al-api"><b>void <a name="set_add_blender">set_add_blender</a>(int r, int g, int b, int a);</b></div><br> Enables an additive blender mode for combining translucent or lit truecolor pixels. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_burn_blender">set_burn_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a burn blender mode for combining translucent or lit truecolor pixels. Here the lightness values of the colours of the source image reduce the lightness of the destination image, darkening the image. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_color_blender">set_color_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a color blender mode for combining translucent or lit truecolor pixels. Applies only the hue and saturation of the source image to the destination image. The luminance of the destination image is not affected. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_difference_blender">set_difference_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a difference blender mode for combining translucent or lit truecolor pixels. This makes an image which has colours calculated by the difference between the source and destination colours. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_dissolve_blender">set_dissolve_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a dissolve blender mode for combining translucent or lit truecolor pixels. Randomly replaces the colours of some pixels in the destination image with those of the source image. The number of pixels replaced depends on the alpha value (higher value, more pixels replaced; you get the idea :). <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_dodge_blender">set_dodge_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a dodge blender mode for combining translucent or lit truecolor pixels. The lightness of colours in the source lighten the colours of the destination. White has the most effect; black has none. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_hue_blender">set_hue_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a hue blender mode for combining translucent or lit truecolor pixels. This applies the hue of the source to the destination. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_invert_blender">set_invert_blender</a>(int r, int g, int b, int a);</b></div><br> Enables an invert blender mode for combining translucent or lit truecolor pixels. Blends the inverse (or negative) colour of the source with the destination. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_luminance_blender">set_luminance_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a luminance blender mode for combining translucent or lit truecolor pixels. Applies the luminance of the source to the destination. The colour of the destination is not affected. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_multiply_blender">set_multiply_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a multiply blender mode for combining translucent or lit truecolor pixels. Combines the source and destination images, multiplying the colours to produce a darker colour. If a colour is multiplied by white it remains unchanged; when multiplied by black it also becomes black. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <blockquote class="eref"><em><b>Examples using this:</b></em> <a class="eref" href="alleg045.html#exalpha" title="Creating and using 32 bit RGBA sprites.">exalpha</a>.</blockquote> <div class="al-api"><b>void <a name="set_saturation_blender">set_saturation_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a saturation blender mode for combining translucent or lit truecolor pixels. Applies the saturation of the source to the destination image. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_screen_blender">set_screen_blender</a>(int r, int g, int b, int a);</b></div><br> Enables a screen blender mode for combining translucent or lit truecolor pixels. This blender mode lightens the colour of the destination image by multiplying the inverse of the source and destination colours. Sort of like the opposite of the multiply blender mode. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_blender_mode">set_blender_mode</a>(BLENDER_FUNC b15, b16, b24, int r, g, b, a);</b></div><br> Specifies a custom set of truecolor blender routines, which can be used to implement whatever special interpolation modes you need. This function shares a single blender between the 24 and 32-bit modes. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_blender_mode_ex" title="An even more complex version of set_blender_mode().">set_blender_mode_ex</a>, <a class="xref" href="#set_trans_blender" title="Enables a truecolor blender.">set_trans_blender</a>, <a class="xref" href="#color_map" title="Global pointer to the color mapping table.">color_map</a>, <a class="xref" href="alleg014.html#draw_trans_sprite" title="Draws a sprite blending it with the destination.">draw_trans_sprite</a>, <a class="xref" href="alleg014.html#draw_lit_sprite" title="Draws a sprite tinted with a specific color.">draw_lit_sprite</a>, <a class="xref" href="#drawing_mode" title="Sets the graphics drawing mode.">drawing_mode</a>.</blockquote> <div class="al-api"><b>void <a name="set_blender_mode_ex">set_blender_mode_ex</a>(BLENDER_FUNC b15, b16, b24, b32, b15x, b16x, b24x, int r, g, b, a);</b></div><br> Like set_blender_mode(), but allows you to specify a more complete set of blender routines. The b15, b16, b24, and b32 routines are used when drawing pixels onto destinations of the same format, while b15x, b16x, and b24x are used by draw_trans_sprite() and draw_trans_rle_sprite() when drawing RGBA images onto destination bitmaps of another format. These blenders will be passed a 32-bit x parameter, along with a y value of a different color depth, and must try to do something sensible in response. <blockquote class="xref"><em><b>See also:</b></em> <a class="xref" href="#set_blender_mode" title="Specifies a custom set of truecolor blender routines.">set_blender_mode</a>, <a class="xref" href="#set_alpha_blender" title="Enables a special alpha-channel blending mode.">set_alpha_blender</a>.</blockquote> <hr><div class="al-back-to-contents"><a href="allegro.html">Back to contents</a></div> </body> </html>