
Contantes y Apis
-------------------
Public Const SRCCOPY As Integer = &HCC0020
Public Const SRCINVERT As Integer = &H660046
Public Const SRCAND As Integer = &H8800C6
...
Declare Auto Function BitBlt Lib "GDI32.DLL" ( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Int32) As Boolean
Function
-------------------
Public Sub BitBlt2(ByRef Destino As PictureBox, ByVal dX As Integer, ByVal dY As Integer, ByVal dW As Integer, ByVal dH As Integer, ByVal Origen As PictureBox, ByVal sX As Integer, ByVal sY As Integer, ByVal Flag As Integer)
Dim srcPic As Graphics = Destino.CreateGraphics'Get a Graphics Object from the form
Dim orgPic As Graphics = Origen.CreateGraphics'Get a Graphics Object from the to
Dim srcBmp As New Bitmap(src.Width, src.Height, srcPic) 'Create a EMPTY bitmap from that graphics
Dim srcMem As Graphics = Graphics.FromImage(srcBmp)'Create a Graphics object in memory from that bitmap
Dim HDC1 As IntPtr = orgPic.GetHdc'get the IntPtr's of the graphics
Dim HDC2 As IntPtr = srcMem.GetHdc'get the IntPtr's of the graphics
'Set the picture
BitBlt(HDC2, dX, dY, dW, dH, HDC1, sX, sY, Flag)
'Clone the bitmap so we can dispose this one
If Not Destino.Image Is Nothing Then Destino.Image.Dispose()
Destino.Image = srcBmp.Clone
'Clean Up
orgPic.ReleaseHdc(HDC1)
orgPic.Dispose()
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-31928-1.html
期待