关于一些透明窗体所需的的函数

效果图:

白云顠顠。。

 

   

1.DIB32位, 预乘alpha

proc AlphaPreMul uses ebx edi, pBitDst,pDstRect,dwDstWight
    local   dwWight:DWORD,dwHight:DWORD
    ;---------------------------------------
    mov     edi,[pBitDst]
    mov     edx,[pDstRect]      ;(p,q)
    
    mov     eax,[edx+RECT.right]
    test    eax,eax
    jz      .exit
    mov     [dwWight],eax

    mov     eax,[edx+RECT.bottom]
    test    eax,eax
    jz      .exit
    mov     [dwHight],eax
    
    mov     eax,[dwDstWight]
    ; shl     eax,2
    mov     ecx,[edx+RECT.top]
    imul    eax,ecx
    mov     ecx,[edx+RECT.left]
    lea     eax,[eax+ecx*4]
    add     edi,eax             ;pDstData start
    ;---------------------------------------
.loopy:
    mov     ebx,[dwWight]
    push    edi
.loopx:
    mov     cl,[edi+3]  ;alpha
    
    mov     al,[edi]
    mul     cl          ;ax=al*cl
    mov     [edi],ah
    
    mov     al,[edi+1]
    mul     cl          ;ax=al*cl
    mov     [edi+1],ah
    
    mov     al,[edi+2]
    mul     cl          ;ax=al*cl
    mov     [edi+2],ah
        
    add     edi,4
    
    sub     ebx,1
    jnz     .loopx
    pop     edi
    add     edi,[dwDstWight]
    
    sub     [dwHight],1
    jnz     .loopy
    
.exit:
    ret
endp


2. Alpha 混合,针对DIB32数据

proc AlphaBlend32 uses ebx esi edi, pBitDst,pDstRect,dwDstWight,pBitSrc,pSrcPoint,dwSrcWight
    local   dwWight:DWORD,dwHight:DWORD
    mov     esi,[pBitSrc]
    mov     edx,[pSrcPoint]      ;(p,q)
    mov     eax,[dwSrcWight]
    ; shl     eax,2
    mov     ecx,[edx+POINT.y]
    imul    eax,ecx
    mov     ecx,[edx+POINT.x]
    lea     eax,[eax+ecx*4]
    add     esi,eax             ;pSrcData start
    ;---------------------------------------
    mov     edi,[pBitDst]
    mov     edx,[pDstRect]      ;(p,q)
    
    mov     eax,[edx+RECT.right]
    test    eax,eax
    jz      .exit
    mov     [dwWight],eax

    mov     eax,[edx+RECT.bottom]
    test    eax,eax
    jz      .exit
    mov     [dwHight],eax
    
    mov     eax,[dwDstWight]
    ; shl     eax,2
    mov     ecx,[edx+RECT.top]
    imul    eax,ecx
    mov     ecx,[edx+RECT.left]
    lea     eax,[eax+ecx*4]
    add     edi,eax             ;pDstData start
    ;---------------------------------------
.loopy:
    mov     ebx,[dwWight]
    push    edi
    push    esi
.loopx:
    mov     cl,255
    mov     dl,255
    sub     cl,[esi+3]
    
    mov     al,[edi]
    mul     cl          ;ax=al*cl
    ; add     ax,128
    ; div     dl          ;al=ax/dl
    add     ah,[esi]
    mov     [edi],ah
    
    mov     al,[edi+1]
    mul     cl          ;ax=al*cl
    ; add     ax,128
    ; div     dl          ;al=ax/dl
    add     ah,[esi+1]
    mov     [edi+1],ah
    
    mov     al,[edi+2]
    mul     cl          ;ax=al*cl
    ; add     ax,128
    ; div     dl          ;al=ax/dl
    add     ah,[esi+2]
    mov     [edi+2],ah
    
    mov     al,[edi+3]
    mul     cl          ;ax=al*cl
    ; add     ax,128
    ; div     dl          ;al=ax/dl
    add     ah,[esi+3]
    mov     [edi+3],ah
    add     esi,4
    add     edi,4
    
    sub     ebx,1
    jnz     .loopx
    pop     esi
    pop     edi
    add     esi,[dwSrcWight]
    add     edi,[dwDstWight]
    
    sub     [dwHight],1
    jnz     .loopy
    
.exit:
    ret
endp


3. DIB32数据的部分拷贝

proc Dib32Copy uses esi edi, pBitDst,pDstRect,dwDstWight,pBitSrc,pSrcPoint,dwSrcWight
    local   dwWight:DWORD,dwHight:DWORD
    mov     esi,[pBitSrc]
    mov     edx,[pSrcPoint]      ;(p,q)
    mov     eax,[dwSrcWight]
    ; shl     eax,2
    mov     ecx,[edx+POINT.y]
    imul    eax,ecx
    mov     ecx,[edx+POINT.x]
    lea     eax,[eax+ecx*4]
    add     esi,eax             ;pSrcData start
    ;---------------------------------------
    mov     edi,[pBitDst]
    mov     edx,[pDstRect]      ;(p,q)
    
    mov     eax,[edx+RECT.right]
    test    eax,eax
    jz      .exit
    shl     eax,2
    mov     [dwWight],eax

    mov     eax,[edx+RECT.bottom]
    test    eax,eax
    jz      .exit
    mov     [dwHight],eax
    
    mov     eax,[dwDstWight]
    ; shl     eax,2
    mov     ecx,[edx+RECT.top]
    imul    eax,ecx
    mov     ecx,[edx+RECT.left]
    lea     eax,[eax+ecx*4]
    add     edi,eax             ;pDstData start
    ;---------------------------------------
.loopy:
    invoke  RtlMoveMemory,edi,esi,[dwWight]
    
    add     esi,[dwSrcWight]
    add     edi,[dwDstWight]
    
    sub     [dwHight],1
    jnz     .loopy
    
.exit:
    ret
endp


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值