zoukankan      html  css  js  c++  java
  • Remark of BLENDFUNCTION from MSDN

    Remarks

    When the AlphaFormat member is AC_SRC_ALPHA, the source bitmap must be 32 bpp. If it is not, the AlphaBlend function will fail.

    When the BlendOp member is AC_SRC_OVER, the source bitmap is placed over the destination bitmap based on the alpha values of the source pixels.

    1.If the source bitmap has no per-pixel alpha value (that is, AC_SRC_ALPHA is not set), the SourceConstantAlpha value determines the blend of the source and destination bitmaps, as shown in the following table. Note that SCA is used for SourceConstantAlpha here. Also, SCA is divided by 255 because it has a value that ranges from 0 to 255.

    Dst.Red = Src.Red * (SCA/255.0) + Dst.Red * (1.0 - (SCA/255.0))
    Dst.Green = Src.Green * (SCA/255.0) + Dst.Green * (1.0 - (SCA/255.0))
    Dst.Blue = Src.Blue * (SCA/255.0) + Dst.Blue * (1.0 - (SCA/255.0))

    If the destination bitmap has an alpha channel, then the blend is as follows.

    Dst.Alpha = Src.Alpha * (SCA/255.0) + Dst.Alpha * (1.0 - (SCA/255.0))

    2.If the source bitmap does not use SourceConstantAlpha (that is, it equals 0xFF), the per-pixel alpha determines the blend of the source and destination bitmaps, as shown in the following table.

    Dst.Red = Src.Red + (1 - Src.Alpha) * Dst.Red
    Dst.Green = Src.Green + (1 - Src.Alpha) * Dst.Green
    Dst.Blue = Src.Blue + (1 - Src.Alpha) * Dst.Blue

    If the destination bitmap has an alpha channel, then the blend is as follows.

    Dest.Alpha = Src.Alpha + (1 - Src.Alpha) * Dst.Alpha

    3.If the source has both the SourceConstantAlpha (that is, it is not 0xFF) and per-pixel alpha, the source is pre-multiplied by the SourceConstantAlpha and then the blend is based on the per-pixel alpha. The following tables show this. Note that SourceConstantAlpha is divided by 255 because it has a value that ranges from 0 to 255.

    Src.Red = Src.Red * SourceConstantAlpha / 255.0;
    Src.Green = Src.Green * SourceConstantAlpha / 255.0;
    Src.Blue = Src.Blue * SourceConstantAlpha / 255.0;
    Src.Alpha = Src.Alpha * SourceConstantAlpha / 255.0;
    Dst.Red = Src.Red + (1 - Src.Alpha) * Dst.Red
    Dst.Green = Src.Green + (1 - Src.Alpha) * Dst.Green
    Dst.Blue = Src.Blue + (1 - Src.Alpha) * Dst.Blue
    Dst.Alpha = Src.Alpha + (1 - Src.Alpha) * Dst.Alpha

    ===========================分割线===========================

     2.

    Dst.Red = Src.Red + (1 - (Src.Alpha/255.0)) * Dst.Red
    Dst.Green = Src.Green + (1 - (Src.Alpha/255.0)) * Dst.Green
    Dst.Blue = Src.Blue + (1 - (Src.Alpha/255.0)) * Dst.Blue
    Dest.Alpha = Src.Alpha + (1 - (Src.Alpha/255.0)) * Dst.Alpha

    3.

    srcAlpha = Src.Alpha  
    Src.Red = Src.Red * SourceConstantAlpha / 255.0;
    Src.Green = Src.Green * SourceConstantAlpha / 255.0;
    Src.Blue = Src.Blue * SourceConstantAlpha / 255.0;
    Src.Alpha = Src.Alpha * SourceConstantAlpha / 255.0;
    Dst.Red = Src.Red + (1 - (srcApha/255.0)) * Dst.Red
    Dst.Green = Src.Green + (1 - (srcApha/255.0)) * Dst.Green
    Dst.Blue = Src.Blue + (1 - (srcApha/255.0)) * Dst.Blue
    Dst.Alpha = Src.Alpha + (1 - (srcApha/255.0)) * Dst.Alpha

     MSDN 备注有点错误.应该先除以255.0的

  • 相关阅读:
    求助:C#读文本文件(编码未知)的问题
    求助:字符的显示问题
    常用的xml文件操作
    关于旧表导入新表的数据冲突问题
    通过批处理管理安装windows服务
    windows服务,批处理安装
    ajax的请求的超时处理
    消息队列的使用
    c#程序执行cmd命令
    dynamic(翻译)
  • 原文地址:https://www.cnblogs.com/xuchonglei/p/3442261.html
Copyright © 2011-2022 走看看