hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha(回音)
俺是个中高手???
bitblt中,最后的参数取srcAnd即可实现透明
任意透明度嘛,试试源图象跟某个灰度值先用BitBlt or运算一下,再合成

解决方案 »

  1.   

    up ,我也是用它作小动画,大的用dx
      

  2.   

    逐点算,计算透明后的颜色透明度计算函数
    Public Function TMC(TMD As Single, UpC As Long, DnC As Long) As Long
    'TMD:透明度。0:完全透明;1:不透明。
    'UpC:上层色
    'DownC:下层色
        Dim UpR As Long, UpG As Long, UpB As Long
        Dim DnR As Long, DnG As Long, DnB As Long
        Dim OutR As Long, OutG As Long, OutB As Long
        
        UpR = UpC And &HFF
        UpG = (UpC And &HFF00&) \ &H100
        UpB = (UpC And &HFF0000) \ &H10000
        DnR = DnC And &HFF
        DnG = (DnC And &HFF00&) \ &H100
        DnB = (DnC And &HFF0000) \ &H10000
        
        OutR = DnR + CLng((UpR - DnR) * TMD)
        If OutR < 0 Then OutR = 0
        If OutR > 255 Then OutR = 255
        OutG = DnG + CLng((UpG - DnG) * TMD)
        If OutG < 0 Then OutG = 0
        If OutG > 255 Then OutG = 255
        OutB = DnB + CLng((UpB - DnB) * TMD)
        If OutB < 0 Then OutB = 0
        If OutB > 255 Then OutB = 255
        TMC = RGB(OutR, OutG, OutB) ' OutR + OutG * &H100& + OutB * &H10000
        
    End Function如果要求速度
    要使用DIB
    一个例子:http://www.21code.com/codebase/?pos=down&id=1754
      

  3.   

    我在这方面的水平是,差啊,所以,我来学习
    人总是要成长的,让我们大家一起在CSDN里成长为新一代的高手吧!
    想吵架的人闪一边去,我们只来学习,不学习的请安静!!!
      

  4.   

    请参阅:
    Public Function AddPictureBits(Pic As PictureBox, PicTo As PictureBox, AddPic As PictureBox, AddPicFor As PictureBox, FileName As String, Value As Integer)
    Dim i As Integer, j As Integer
    Dim bit2Width As Long
    Dim bitWidth As Long
    Dim hOldMap As Long
    Dim Pic2Bits() As Byte
    Dim PicBits() As Byte
    Dim ByteArray() As Byte
    Dim iBitmap As Long, iDC As Long
    Dim i2Bitmap As Long, i2DC As Long
    Dim bi24BitInfo As BITMAPINFO
    Dim bi24Bit2Info As BITMAPINFO
    Dim RC As Integer, GC As Integer, BC As Integer
    Dim VRc As Integer, VGc As Integer, VBc As Integer
    If Value > 100 Or Value < 0 Then Value = 50
    PicTo.Height = Pic.Height
    PicTo.Width = Pic.Width
    PicTo.Picture = Pic.Image
    AddPicFor.Height = PicTo.Height
    AddPicFor.Width = PicTo.Width
    AddPic.Picture = LoadPicture(FileName)
    AddPicFor.PaintPicture AddPic, 0, 0, PicTo.Width, PicTo.Height, 0, 0, AddPic.Width, AddPic.Height
    With bi24BitInfo.bmiHeader
        .biBitCount = 24
        .biCompression = BI_RGB
        .biPlanes = 1
        .biSize = Len(bi24BitInfo.bmiHeader)
        .biWidth = PicTo.ScaleWidth
        .biHeight = PicTo.ScaleHeight
        .biSizeImage = ((.biWidth * 3 + 3) And &HFFFFFFFC) * .biHeight
    End With
    iDC = CreateCompatibleDC(0)
    iBitmap = CreateDIBSection(iDC, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
    If iBitmap Then
      hOldMap = SelectObject(iDC, iBitmap)
    Else
      DeleteObject iDC
      Exit Function
    End If
    With bi24Bit2Info.bmiHeader
        .biBitCount = 24
        .biCompression = BI_RGB
        .biPlanes = 1
        .biSize = Len(bi24BitInfo.bmiHeader)
        .biWidth = PicTo.ScaleWidth
        .biHeight = PicTo.ScaleHeight
        .biSizeImage = ((.biWidth * 3 + 3) And &HFFFFFFFC) * .biHeight
    End With
    i2DC = CreateCompatibleDC(0)
    i2Bitmap = CreateDIBSection(i2DC, bi24Bit2Info, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
    If i2Bitmap Then
      hOldMap = SelectObject(i2DC, i2Bitmap)
    Else
      DeleteObject i2DC
      Exit Function
    End If
    BitBlt iDC, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, Pic.hdc, 0, 0, vbSrcCopy
    bitWidth = (bi24BitInfo.bmiHeader.biWidth * 3 + 3) And &HFFFFFFFC
    ReDim PicBits(0 To bitWidth, 0 To bi24BitInfo.bmiHeader.biHeight) As Byte
    ReDim ByteArray(0 To bitWidth, 0 To bi24BitInfo.bmiHeader.biHeight) As Byte
    GetBitmapBits iBitmap, bi24BitInfo.bmiHeader.biSizeImage, PicBits(0, 0)
    BitBlt i2DC, 0, 0, bi24Bit2Info.bmiHeader.biWidth, bi24Bit2Info.bmiHeader.biHeight, AddPicFor.hdc, 0, 0, vbSrcCopy
    bit2Width = (bi24Bit2Info.bmiHeader.biWidth * 3 + 3) And &HFFFFFFFC
    ReDim Pic2Bits(0 To bitWidth, 0 To bi24BitInfo.bmiHeader.biHeight) As Byte
    GetBitmapBits i2Bitmap, bi24Bit2Info.bmiHeader.biSizeImage, Pic2Bits(0, 0)
    For i = 0 To bitWidth - 2 Step 3
      For j = 0 To bi24BitInfo.bmiHeader.biHeight
        RC = PicBits(i + 2, j)
        GC = PicBits(i + 1, j)
        BC = PicBits(i, j)
        VRc = Pic2Bits(i + 2, j)
        VGc = Pic2Bits(i + 1, j)
        VBc = Pic2Bits(i, j)
        ByteArray(i + 2, j) = RC * (100 - Value) / 100 + VRc * Value / 100
        ByteArray(i + 1, j) = GC * (100 - Value) / 100 + VGc * Value / 100
        ByteArray(i, j) = BC * (100 - Value) / 100 + VBc * Value / 100
      Next j
    Next i
    SetBitmapBits iBitmap, bi24BitInfo.bmiHeader.biSizeImage, ByteArray(0, 0)
    BitBlt PicTo.hdc, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, iDC, 0, 0, vbSrcCopy
    If hOldMap Then DeleteObject SelectObject(iDC, hOldMap)
    If hOldMap Then DeleteObject SelectObject(i2DC, hOldMap)
    DeleteObject iDC
    DeleteObject i2DC
    AddPictureBits = True
    End Function
    '                                                原创,参考API-Guide
    --------------------------------------------------------------------
    这是当初编写的一段,采用了DIB技术,不过为了适应你的要求,应该改改代码。
    --------------------------------------------------------------------
    另,和Zyl910一样,推荐参阅http://www.21code.com/codebase/?pos=down&id=1754
    --------------------------------------------------------------------