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

来源:互联网 发布:局域网控制电脑软件 编辑:程序博客网 时间:2024/06/05 23:46

效果图:

白云顠顠。。

 

   

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:    retendp


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:    retendp


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:    retendp