The first article: http://www.sudu.cn/info/html/edu/database/20071225/21843.html
The article code is as follows:
Long origcolor
Long origmode
Long savedc
Long maskdc
Long invdc
Long resultdc
Long hsavebmp
Long hmaskbmp
Long hinvbmp
Long hresultbmp
Long hsaveprevbmp
Long hmaskprevbmp
Long hinvprevbmp
Long hdestprevbmp
Long HSRCDC
Long hdestdc
Long nwidth, nheight
Long transcolor
Long ret, hbitmap
String ls_tmp
HSRCDC=CreateCompatibleDC (GetDC (handle (p_2)))
Hdestdc=GetDC (handle (p_1))
Nwidth=unitstopixels (p_2. Width, xunitstopixels!)
Nheight=unitstopixels (p_2. Height, yunitstopixels!)
//here due to pb default in pb unit units and the API processing unit of measure in pixel units so we need to convert the unit
Transcolor=0
//configuration to transparent RGB color here, here is black;
Ls_tmp="zp. BMP"
Ls_tmp hbitmap=LoadImage (0, 0, 0, 0, 16)
Savedc=CreateCompatibleDC (hdestdc)
Maskdc=CreateCompatibleDC (hdestdc)
Invdc=CreateCompatibleDC (hdestdc)
Resultdc=CreateCompatibleDC (hdestdc)
Hmaskbmp=CreateBitmap (nwidth, nheight, 1, 1, 0)
Hinvbmp=CreateBitmap (nwidth, nheight, 1, 1, 0)
Hresultbmp=CreateCompatibleBitmap (hdestdc, nwidth, nheight)
Hsavebmp=CreateCompatibleBitmap (hdestdc, nwidth, nheight)
Ret=SelectObject (HSRCDC hbitmap)
Hsaveprevbmp=SelectObject (savedc, hsavebmp)
Hmaskprevbmp=SelectObject (maskdc hmaskbmp)
Hinvprevbmp=SelectObject (invdc hinvbmp)
Hdestprevbmp=SelectObject (resultdc hresultbmp)
Origcolor=SetBKColor (HSRCDC transcolor)
Ret=BitBlt (maskdc, 0, 0, nwidth, nheight, HSRCDC, 0, 0, 13369376)
//note: the parameters of 13369376 as the bitblt function - srccopy, said copies the source rectangle directly to the destination rectangle
Transcolor=SetBKColor (HSRCDC origcolor)
Ret=BitBlt (invdc, 0, 0, nwidth, nheight, maskdc, 0, 0, 3342344)
//note: the parameters of 3342244 as the bitblt function - notsrccopy, said color after the not copy the source rectangle into a destination rectangle area
Ret=BitBlt (resultdc, 0, 0, nwidth, nheight, hdestdc, 0, 0, 13369376)
Ret=BitBlt (resultdc, 0, 0, nwidth, nheight, maskdc, 0, 0, 8913094)
//note: 8913094 - srcand as the bitblt function parameters, by using the (and) operation and operator said to the color of the source and destination rectangle region merging
Ret=BitBlt (savedc, 0, 0, nwidth, nheight, HSRCDC, 0, 0, 13369376)
Ret=BitBlt (savedc, 0, 0, nwidth, nheight, invdc, 0, 0, 8913094)
Ret=BitBlt (resultdc, 0, 0, nwidth, nheight, savedc, 0, 0, 6684742)
//note: the parameters of 6684742 as the bitblt function - srcinvert, said by using the Boolean xor (exclusive or) of the operator to the color of the source and destination rectangle merger
Ret=BitBlt (hdestdc, 0, 0, nwidth, nheight, resultdc, 0, 0, 13369376)
Ret=SelectObject (savedc, hsaveprevbmp)
Ret=SelectObject (resultdc hdestprevbmp)
Ret=SelectObject (maskdc hmaskprevbmp)
Ret=SelectObject (invdc hinvprevbmp)
Ret=DeleteObject (hsavebmp)
Ret=DeleteObject (hmaskbmp)
Ret=DeleteObject (hinvbmp)
Ret=DeleteObject (hresultbmp)
Ret=DeleteDC (savedc)
Ret=DeleteDC (invdc)
Ret=DeleteDC (maskdc)
Ret=DeleteDC (resultdc)
Ret=ReleaseDC (handle (p_1), HSRCDC)
Ret=ReleaseDC (handle (p_3), hdestdc)
The second article: http://www.cndw.com/tech/program/2006051873498.asp
Content is as follows:
In VB, if you try to make a tree with a bird images in the background, you will find that the tree will be bird covered
Live a rectangular area (i.e., bird images of rectangle), we can through the following method to make the bird on the picture of other department
Points is clear: we can use a BitBlt WinAPI functions to a series of a graphics operation to achieve
This end,
Function declaration:
Declare the Function BitBlt Lib "gdi32" Alias "BitBlt" (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 Long)
Parameter interpretation:
Environmental goals: hDestDC - equipment environment; X - the top left corner; Y - the top; NWidth - wide;
High nHeight -
Source environment: hSrcDC - source equipment environment; XSrc sources - the top left corner; YSrc - the top of the source;
DwRop - processing operations, such as vbSrcAnd; VbSrcAnd; VbSrcCopy; VbSrcErase;
VbSrcInvert etc.
(target environment or source environment only Picture, Form or Printer objects, each unit for pixels,)
Before processing, we need to deal with the picture of the bird: first a copy of the same graphics, it should be transparent
Bird (background) set to black (set this picture sPic), will be treated as a figure to do the following: to copy of
Party (bird) set to black, the rest set the background (bird) to white (set the photo Mask),
A tree graph name dPic,
Finally, please add the following code:
R=BitBlt (dPic. HDC, 0, 0, sPic. Width, sPic. Height, Mask, HDC, 0, 0, vbScrCopy)
R=BitBlt (dPic. HDC, 0, 0, sPic. Width, sPic. Height, sPic. HDC, 0, 0, vbScrInvert)
Postscript:
1, VB PaintPicture methods provide similar functionality, but as fast as this method;
2, slightly to add some code on this method, it is not hard to realize the animation display,
3, VB examples CallDlls of using this method,
CodePudding user response:
How no one came to the problem solving??CodePudding user response:
What do you want to do?You want us to do?
CodePudding user response:
Put it into pb?CodePudding user response:
Add my QQ, MSN, :)