Hi again Erel,
Please find below as requested!
BitBlt quite simply makes copies of portions of the screen.
This is done by accessing the Windows hDC and other low level mind numbing things.
This is similar to your:
drawer.New1("Form1",true)
rectSrc.New1(0,0,bmp.Width,bmp.Height) 'The source rectangle.
rectDest.New1(120,120,36,32)
drawer.DrawImage1(bmp.Value,rectSrc.Value,rectDest.Value,true)
Form1.DrawString("Try to catch the smiley",12,10,10,200,50,cBlack)
It is a very fast routine, you dont get the flickering as you do in tha above routine
This has been on the go since VB3 and I still use it in VB6:
Declare the functions that are in the GDI32.DLL file so we can use them in VB.NET.
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
Private Function copyRect(ByVal src As PictureBox, _
ByVal rect As RectangleF) As Bitmap
'Get a Graphics Object from the form
Dim srcPic As Graphics = src.CreateGraphics
'Create a EMPTY bitmap from that graphics
Dim srcBmp As New Bitmap(src.Width, src.Height, srcPic)
'Create a Graphics object in memory from that bitmap
Dim srcMem As Graphics = Graphics.FromImage(srcBmp)
'get the IntPtr's of the graphics
Dim HDC1 As IntPtr = srcPic.GetHdc
'get the IntPtr's of the graphics
Dim HDC2 As IntPtr = srcMem.GetHdc
'get the picture
BitBlt(HDC2, 0, 0, rect.Width, _
rect.Height, HDC1, rect.X, rect.Y, 13369376)
'Clone the bitmap so we can dispose this one
copyRect = srcBmp.Clone()
'Clean Up
srcPic.ReleaseHdc(HDC1)
srcMem.ReleaseHdc(HDC2)
srcPic.Dispose()
srcMem.Dispose()
srcMem.Dispose()
End Function
Then all we need to do is call the function to return the image we want:
Dim bmp = CType(copyRect(src, _
New RectangleF(0, 0, 50, src.Height)), Bitmap)
dest.Image = bmp.CloneShorthand:
-or-
dest.Image = CType(copyRect(src, _
New RectangleF(0, 0, 50, src.Height)), Bitmap).Clone
Regards,
Andrew.