您的位置:首页 > 其它

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

2013-08-11 15:47 323 查看
效果图:

白云顠顠。。





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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: