Alpha值在BITMAP中不起作用 [英] Alpha value is not working in BITMAP
问题描述
因此,我的像素数组包含RGBA(RGB和Alpha)值。我想为每个像素应用alpha值。为此,我使用BITMAPV4HEADER和''SetDIBitsToDevice''函数将像素数组绘制到图片框中。但Alpha值不起作用(RGB工作正常)。我怎样才能使用alpha值?
我尝试使用AlphaBlend函数,但它始终将透明度应用于所有像素。我想通过使用(SetDIBitsToDevice)来应用具有不同alpha值的每个像素。
I have the pixel array containing the RGBA (RGB and Alpha) values consequently. I want to apply the alpha value for each pixel. For that I am using BITMAPV4HEADER and ''SetDIBitsToDevice'' function to draw the pixel array into picture box. But the Alpha value is not working (RGB is working fine). How can i use alpha value??
I am tried with AlphaBlend function, but it always apply the transparency to all pixels. I want apply for each pixel with different alpha value by using(SetDIBitsToDevice).
推荐答案
正如在回答上一个问题时已经提到的那样,GDI的功能类似于SetDIBitsToDevice
将清除位图的alpha值。请参阅 Alpha混合位图 [ ^ ]在MSDN中如何使用带源alpha值的AlphaBlend
函数。
As already noted in a reply to your previous question, GDI functions likeSetDIBitsToDevice
will clear the alpha values of the bitmap. See Alpha Blending a Bitmap[^] in the MSDN on how to use theAlphaBlend
function with source alpha values.
AlphaBlend的文档说设置bSrcAlpha到255以使用每像素alpha值。你做过吗?
The documentation of AlphaBlend says to set bSrcAlpha to 255 to use the per-pixel alpha values. Have you done that?
这篇关于Alpha值在BITMAP中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!