简体   繁体   中英

Does drawing over an hdc using gdi+ results in a premultiplied by alpha bitmap?

I'm trying to draw some bitmap on a CImage object using GDI+ DrawImage. The resulting CImage bitmap seems to be premultiplied by alpha but I can't find any mention of that in the msdn documentation.

What happens when I draw using DrawImage over an CImage HDC ?

Yes, the result will be pre-multiplied because the AlphaBlend function expects pre-multiplied alphas. This is noted in the documentation AlphaFormat member of the BLENDFUNCTION structure:

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.

Ref: http://msdn.microsoft.com/en-us/library/dd183393(v=vs.85).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM