using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Gdi32
{
///
/// The BLENDFUNCTION structure controls blending by specifying the blending functions for source and destination bitmaps.
///
/// See information on how this function determines the resulting values on MSDN.
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("Wingdi.h", MSDNShortId = "dd183393")]
public struct BLENDFUNCTION
{
///
/// The source blend operation. Currently, the only source and destination blend operation that has been defined is AC_SRC_OVER. For details, see the
/// following Remarks section.
///
public byte BlendOp;
/// Must be zero.
public byte BlendFlags;
///
/// Specifies an alpha transparency value to be used on the entire source bitmap. The SourceConstantAlpha value is combined with any per-pixel alpha
/// values in the source bitmap. If you set SourceConstantAlpha to 0, it is assumed that your image is transparent. Set the SourceConstantAlpha value
/// to 255 (opaque) when you only want to use per-pixel alpha values.
///
public byte SourceConstantAlpha;
///
/// This member controls the way the source and destination bitmaps are interpreted. AlphaFormat has the following value.
///
/// AC_SRC_ALPHA This flag is set when the bitmap has an Alpha channel (that is, per-pixel alpha). Note that the APIs use premultiplied alpha,
/// which means that the red, green and blue channel values in the bitmap must be premultiplied with the alpha channel value. For example, if the
/// alpha channel value is x, the red, green and blue channels must be multiplied by x and divided by 0xff prior to the call.
///
///
public byte AlphaFormat;
/// Initializes a new instance of the struct and sets the alpha value.
/// The alpha.
public BLENDFUNCTION(byte alpha)
{
// AC_SRC_OVER is the only possible value for BlendOp and it equals 0
BlendOp = 0;
BlendFlags = 0;
SourceConstantAlpha = alpha;
// AC_SRC_ALPHA is the only possible value for AlphaFormat and it equals 1
AlphaFormat = 1;
}
/// Gets a value indicating whether this instance is empty.
/// if this instance is empty; otherwise, .
public bool IsEmpty => BlendOp == 0 && BlendFlags == 0 && AlphaFormat == 0 && SourceConstantAlpha == 0;
}
}
}