![]() As a Direct2D type, this color would be represented as (1, 0, 0, 0.5). Suppose the desired color is pure red (100% intensity) with 50% alpha. Here is an example of the difference between straight alpha and premultiplied alpha. However, this format is not appropriate for storing in an image file. This format is more efficient to render than straight alpha, because the term (af Cf) from the alpha-blending formula is pre-computed. The color components of the pixel represent the color intensity multiplied by the alpha value. The color components of the pixel represent the color intensity prior to alpha blending. Alpha ModeĪ render target also has an alpha mode, which defines how the alpha values are treated. For example, the display might be set to 16-bit color, even though the render target uses 32-bit color. The pixel format might not match the display resolution. To get the pixel format of a render target, call ID2D1RenderTarget::GetPixelFormat. The following illustration shows BGRA pixel layout. To read more about using opacity masks in Direct2D, see Compatible A8 Render Targets Overview. This format contains an 8-bit alpha component, with no RGB components. This format is supported only for hardware devices. In other words, the red and blue components are swapped, relative to DXGI_FORMAT_B8G8R8A8_UNORM. Pixel components are 8-bit unsigned integers, in RGBA order. The components are arranged in BGRA order in memory. All pixel components (red, green, blue, and alpha) are 8-bit unsigned integers. The list is fairly long, but only a few of them are relevant to Direct2D. ![]() The DXGI_FORMAT enumeration defines a list of pixel formats. But you might need to know the pixel format if you are working directly with a bitmap in memory, or if you combine Direct2D with Direct3D or GDI. Direct2D handles all of the internal details of translating color information into pixels. The D2D1_COLOR_F structure does not describe how a pixel is represented in memory. The following image shows the result of this blending operation. For example, suppose the foreground color is (R = 1.0, G = 0.4, B = 0.0), with alpha = 0.6, and the background color is (R = 0.0, G = 0.5, B = 1.0). This formula is applied pairwise to each color component. Where Cb is the background color, Cf is the foreground color, and af is the alpha value of the foreground color. Equivalent to the previous example.Īlpha blending creates translucent areas by blending the foreground color with the background color, using the following formula. You can also specify a color using the D2D1::ColorF class, which derives from the D2D1_COLOR_F structure. For example, the following code specifies magenta. Direct2D uses the D2D1_COLOR_F structure to represent colors. RedĬolor values between 0 and 1 result in different shades of these pure colors. The following table shows the colors that result from various combinations of 100% intensity. For the alpha component, 0.0 means completely transparent, and 1.0 means completely opaque. ![]() For the three color components, the value measures the intensity of the color. In Direct2D, each of these components is a floating-point value with a range of. A fourth component, alpha, measures the transparency of a pixel. Direct2D uses the RGB color model, in which colors are formed by combining different values of red, green, and blue.
0 Comments
Leave a Reply. |