我试了一下这样写:但是不行?! SelectObject TempLayerdC, Picture1.hDC ' Select the current layer's bitmap into the tempoary layer DC
With tempBlend .AlphaFormat = AC_SRC_ALPHA ' 32 bit .BlendFlags = 0 .BlendOp = AC_SRC_OVER .SourceConstantAlpha = 255 End With RtlMoveMemory lBF, tempBlend, 4 ' Copy the blending structure above to a long
AlphaBlend TempDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _ TempLayerdC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF ' Blend the layer onto the temp DC
BitBlt Me.hDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, TempDC, 0, 0, vbSrcCopy ' Copy the rendered layer DC onto the Dest DC
With tempBlend
.AlphaFormat = AC_SRC_ALPHA ' 32 bit
.BlendFlags = 0
.BlendOp = AC_SRC_OVER
.SourceConstantAlpha = 255
End With
RtlMoveMemory lBF, tempBlend, 4 ' Copy the blending structure above to a long
AlphaBlend TempDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
TempLayerdC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF ' Blend the layer onto the temp DC
BitBlt Me.hDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, TempDC, 0, 0, vbSrcCopy ' Copy the rendered layer DC onto the Dest DC
从以上代码片段就能看出一些问题:
1、SelectObject TempLayerdC, Picture1.hDC 有问题,将设备场景选入设备场景?何意?
2、SourceConstantAlpha = 255 没有意义啦,这与BitBlt无异!还AlphaBlend干吗?另外,你的问题太模糊,看不明白,你要的具体效果是什么,似乎就是想将两张位图进行Alpha混合,但又不说现在是什么情况,光说不行,却不说是什么不行?代码还不全,真不知让别人从何分析!