Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use blendfunction structure parameters

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to use the structural parameters of blendfunction. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

BLENDFUNCTION controls transparent blending by specifying the transparent mixing parameters of the source and destination bitmaps. AlphaBlend is the GDI function that comes with Window. We often use it in order to achieve more beautiful results when using GUI. The type of one of its parameters is BLENDFUNCTION.

Blendfunction structure

Typedefstruct_BLENDFUNCTION {

BYTEBlendOp

BYTEBlendFlags

BYTESourceConstantAlpha

BYTEAlphaFormat

} BLENDFUNCTION,*PBLENDFUNCTION,*LPBLENDFUNCTION

Blendfunction parameter editing

BlendOp specifies the source mix operation. The only source and destination mix has been defined as AC_SRC_OVER

BlendFlags must be 0

SourceConstantAlpha specifies an alpha transparency value, which will be used for the entire source bitmap; this SourceConstantAlpha value is combined with the alpha value of each pixel of the source bitmap; if set to 0, your picture is assumed to be transparent; if you need to use the alpha value of each pixel itself, set the Alpha value of 255 (opaque)

The parameter AlphaFormat controls how the source and destination are resolved. The AlphaFormat parameter has the following values:

AC_SRC_ALPHA: when the source has an Alpha channel (that is, when the operation graph itself has transparent channel information), it reminds the system that API must be multiplied by the alpha value before calling the function, that is, the channel values of red, green, and blue at a pixel location on the bitmap must be multiplied by alpha. For example, if the alpha transparency value is x, then the values of the red, green, and blue channels must be multiplied by x and divided by 255 (because the value range of alpha is 0x255) before it can be called.

Apply Notes Editing

1. When the value of the AlphaFormat parameter is AC_SRC_ALPHA, the source bitmap must be 32 bits deep, otherwise the call to the AlphaBland function will fail.

2. When the BlendOp parameter is AC_SRC_OVER, the source bitmap overlays the target bitmap directly according to the alpha transparency value

3. If the source bitmap does not have transparency information (in that case, AC_SRC_ALPHA is not set), the value of SourceConstanAlpha will determine how to mix the source bitmap and the target bitmap, as shown in the following table. SCA in the table represents the value of SourceConstantAlpha. Again, SCA is divided by 255, because it ranges from 0 to 255. 0.

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))

In this case, if the target bitmap has transparency information, the blending method will follow the following formula:

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

This is the end of the article on "how to use blendfunction structural parameters". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report