winapidirect2d

How is the opacity calculated by direct2d when a brush has both opacity and alpha channel less than 1


In direct2d there is the base of all brushes ID2D1Brush which has an opacity set with SetOpacity and there is a solid color brush that uses floating point RGBA colors with alpha channel. There are other brushes but I didn't use them yet. If I set the opacity of the brush and used a color with alpha channel less than 1, how the resulting opacity will be determined? Will one of them override the other? Or the opacity will be the product of opacity value and alpha?


Solution

  • @IInspectable is correct (adding an answer to add photos).

    From my complex brush editor:

    Red picked with full opacity:

    enter image description here

    Red picked with 50% opacity (D2D1_COLOR_F 1,1,1,0.5f)

    enter image description here

    Opacity set per ID2D1Brush also set to 50%

    enter image description here

    So, they are multiplied. The idea is to have a global setting for brushes that contain many colors (linear, radial and bitmap). For a solid brush of course, there is not much meaning.