DrawingOptionsAlphaBlending Property

Gets or sets whether alpha blending is enabled when drawing shapes.
Default value: .

See the online help for image examples.

Definition

Namespace: KGySoft.Drawing.Shapes
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 9.0.0
C#
public bool AlphaBlending { get; set; }

Property Value

Boolean

Remarks

When this property is , the alpha channel of the colors is blended with the target image. The used color space for blending is the target's WorkingColorSpace, or the one that the Quantizer uses (if specified).

Alpha blending may be required in two cases: when the used Brush has transparent colors, or when the AntiAliasing property is .

If this property is , the alpha channel is written directly to the target image. This is usually not desired with anti-aliased shapes, except for already transparent background images, because it may produce alpha pixels along the edges of the shapes, even when the background is fully opaque.

When AlphaBlending is , drawing or filling a shape with a completely transparent Brush will not affect the target image, whereas when it is , a transparent Brush can be used to draw transparent shapes.

Examples

The following images provide a few examples regarding alpha blending:

DescriptionImage Example
Filling a polygon with AntiAliasing = , AlphaBlending = , using a solid brush with 50% transparency on an alpha gradient background. Note that no blending occurs, so the polygon is just filled with the specified alpha color.Polygon filled with 50% transparency, AntiAliasing = false, AlphaBlending = false.
Filling a polygon with AntiAliasing = , AlphaBlending = , using a solid brush with 50% transparency on an alpha gradient background. The blending uses the color space of the target IReadWriteBitmapData, which is linear in this case.Polygon filled with 50% transparency, AntiAliasing = false, AlphaBlending = true.
Filling a polygon with AlphaBlending = , using a completely transparent brush. Note that this way we can "cut" transparent "holes" into a bitmap. If the target does not support transparency, the shape will be filled with the BackColor color of the target bitmap data.Polygon filled with transparency, AlphaBlending = false.
Filling a polygon with AntiAliasing = , AlphaBlending = . When anti-aliasing is enabled, it's not recommended to turn off alpha blending (unless the background is transparent), because it may produce alpha pixels along the edges of the shapes, even when the background is fully opaque.filling a polygin with AntiAliasing = true, AlphaBlending = false.
Filling a polygon with AntiAliasing = , AlphaBlending = .Filling a polygin with AntiAliasing = true, AlphaBlending = true.

See Also