Picture transparent transmission of pure code mode

zhaozj2021-02-16  54

Option ExplicitPublic Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As LongPublic Declare Function CreateCompatibleBitmap Lib "gdi32.dll" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As LongPublic Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As LongPublic Declare Function SetBkColor Lib "gdi32.dll" (ByVal hdc As Long, ByVal crColor As Long) As LongPublic Declare Function BitBlt Lib "gdi32.dll" ( ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As LongPublic Declare Function DeleteDC lib "gdi32.dll" (ByVal hdc As Long) As LongPublic Declare Function DeleteObject lib "gdi32.dll" (ByVal hObject As Long) As LongPublic Declare Function StretchBlt lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long , Byval Y As Long, Byval NHEIGHT As Long, Byval HSRC DC As Long, Byval Ysrc As Long, Byval NSRCWIDTH AS Long, Byval NSRCHEIGHT AS Long, BYVAL DWROP AS Long AS Long

Public function tbitblt (byval x ask, _ byval nwidth as long, _ byval hsrcdc as long, _ byval hsrcdc as long, _ byval xsrc as long, _ byval xsrc, _ byval, _ ByVal Xsrc AS long TransColor As Long) As LongDim hTmpDC As Long, hMonoDC As LongDim hTmpBmp As Long, hMonoBmp As LongDim hTmpBmpOld As Long, hMonoBmpOld As Long hMonoDC = CreateCompatibleDC (0) hMonoBmp = CreateCompatibleBitmap (hMonoDC, nWidth, nHeight) hMonoBmpOld = SelectObject (hMonoDC, hMonoBmp ) hTmpDC = CreateCompatibleDC (hSrcDC) hTmpBmp = CreateCompatibleBitmap (hSrcDC, nWidth, nHeight) hTmpBmpOld = SelectObject (hTmpDC, hTmpBmp) BitBlt hTmpDC, 0, 0, nWidth, nHeight, hSrcDC, xSrc, ySrc, vbSrcCopy

Call setbkcolor (htmpdc, transcolor) Bitblt HMONDC, 0, 0, NWIDTH, NHEIGHT, HTMPDC, 0, 0, VBSRCCPY Bitblt HTMPDC, 0, 0, NWIDTH, NHEIGHT, HMONODC, 0, 0, VBNOTSRCCPY Bitblt HTMPDC, 0, 0, NWIDTH, NHEIGHT, HSRCDC, XSRC, YSRC, VBSRCAND

Bitblt HDestdc, X, Y, NWIDTH, NHEIGHT, HMONODC, 0, 0, VBSRCCPY

Bitblt HDestdc, X, Y, NWIDTH, NHEIGHT, HTMPDC, 0, 0, VBSRCPAINT

Call SelectObject (HTMPDC, HTMPBMPOLD) CALL SELECTOBJECT (HMONDC, HMONOBMPOLD)

Call DeleteDC (hMonoDC) Call DeleteDC (hTmpDC) Call DeleteObject (hMonoBmp) Call DeleteObject (hTmpBmp) Call DeleteObject (hMonoBmpOld) Call DeleteObject (hTmpBmpOld) 'BitBlt Form1.p.hdc, x, y, nWidth, nHeight, hTmpDC, xSrc, YSRC, VBSRCCopy 'Bitblt Form1.p.hdc, X, Y, NWIDTH, NHEIGHT, HMONODC, XSRC, YSRC, VBSRCCPY

End FunctionPublic Function TStretchBlt (ByVal hDestDC As Long, _ ByVal x As Long, ByVal y As Long, _ ByVal nWidth As Long, ByVal nHeight As Long, _ ByVal hSrcDC As Long, _ ByVal xSrc As Long, ByVal ySrc As Long, _ ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, _ ByVal TransColor As Long) Dim hMidDC As Long, hMidBmp As Long, hMidBmpOld As Long hMidDC = CreateCompatibleDC (hSrcDC) hMidBmp = CreateCompatibleBitmap (hSrcDC, nWidth, nHeight) hMidBmpOld = SelectObject (hMidDC, hMidBmp) StretchBlt hMidDC, 0, 0, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, vbSrcCopy TBitBlt hDestDC, x, y, nWidth, nHeight, hMidDC, 0, 0, TransColor Call SelectObject (hMidDC, hMidBmpOld) Call DELETEDC (HMIDDC) Call DeleteObject (HMIDBMP) Call deleteObject (HMIDBMPOLD) End Function is basically the same as Bitblt

转载请注明原文地址:https://www.9cbs.com/read-21541.html

New Post(0)