Colors become darker with semi-transparency in buffered objects
Description
Under certain conditions, colors become darker, if buffered objects are used in combination with semi-transparency.
Solution
Buffered objects are usually used for optimization purpose, to avoid a redraw of all contents while the object is animated (e.g.: move- or fade in/out). The described phenomenon can be observed, if a buffered object with semi transparency is drawn into the framebuffer.
The reason is that the buffer memory is pre-initialized with the RGBA8888 color 0x00000000 which is black color from the RGB value and full transparent from the alpha value. By default EmWi is drawing all content objects (rectangles, borders, text, images, etc.) in blend mode to the black (transparent) buffer. In a second step, the buffer is drawn into the framebuffer. At that time the second blending causes a darker appearance of the object.
If the same object is drawn without buffered mode, it will appear correct, since there is only one blending step.
The only way to avoid this effect is if the Hardware supports pre-multiplied alpha values. But this feature is not available on most of the currently used platforms. Since the realization of pre-multiplied colors in Software is consuming too much CPU performance we have to find some kind of workaround to eliminate this shading effect.
Workaround A)
If possible, please avoid buffered mode together with blended, semi-transparent objects.
Workaround B)
To eliminate the shading effect you can use the color of the semitransparent part as RGB value for the pre-initialization of the buffer memory. This means if the semitransparent part has RGBA color 0xFFFFFFC0, we use color 0xFFFFFF00 for the pre-initialization instead of 0x00000000. As shown in the image below "buffered semi-transparent with white pre-initialization 0xFFFFFF00" the effect can be totally eliminated by this trick.
Workaround C)
Also by using the copy mode for buffered objects instead of blend mode the effect can be totally eliminated. The disadvantage is that this does only work on full transparent background. In copy mode everything behind the object is overwritten and the OSD semi-transparency will be directly to the video. In the image below you can see this in the object "buffered semi-transparent in copy mode".

See also
Keywords
Blend mode, copy mode, buffered, initialization, shade, shading, darker, color, pre-multiplied alpha values, RGBA
Last update on 2010-08-19 by Mario Stefanutti.