G
Guest
I'm trying to copy a part of an image (a rectangle) width the bitblt api
function, bu i receive an error when i try to do it. The error is the
following, that i will try to translate because its in another language:
"A call for the function PInvoke “GestCeph! GestCeph.Geral:: BitBltâ€
unbalanced the stack. It is probable that the managed signature PInvoke does
not correspond to the signature of destination not managed. It verifies if
the convention of call and the parameters of the PInvoke signature correspond
to the signature of destination not managed."
the function where the bitblt gives an error is this one:
Public Function makeCopy(ByVal src As System.Windows.Forms.PictureBox,
ByVal rect As RectangleF) As Bitmap
Dim srcPic As Graphics = src.CreateGraphics
Dim srcBmp As New Bitmap(src.Width, src.Height, srcPic)
Dim srcMem As Graphics = Graphics.FromImage(srcBmp)
Dim HDC1 As IntPtr = srcPic.GetHdc
Dim HDC2 As IntPtr = srcMem.GetHdc
BitBlt(HDC2, 0, 0, rect.Width, rect.Height, HDC1, rect.X, rect.Y,
&HCC0020)
copyRect = srcBmp.Clone()
srcPic.ReleaseHdc(HDC1)
srcPic.ReleaseHdc(HDC2)
srcPic.Dispose()
srcMem.Dispose()
End Function
The following is the calling statment
picZoom.Image = MainDrawPics.makeCopy(picDraw, New RectangleF(0, 0, 50, 50))
Can anyone help me?
My thanks in advanced
function, bu i receive an error when i try to do it. The error is the
following, that i will try to translate because its in another language:
"A call for the function PInvoke “GestCeph! GestCeph.Geral:: BitBltâ€
unbalanced the stack. It is probable that the managed signature PInvoke does
not correspond to the signature of destination not managed. It verifies if
the convention of call and the parameters of the PInvoke signature correspond
to the signature of destination not managed."
the function where the bitblt gives an error is this one:
Public Function makeCopy(ByVal src As System.Windows.Forms.PictureBox,
ByVal rect As RectangleF) As Bitmap
Dim srcPic As Graphics = src.CreateGraphics
Dim srcBmp As New Bitmap(src.Width, src.Height, srcPic)
Dim srcMem As Graphics = Graphics.FromImage(srcBmp)
Dim HDC1 As IntPtr = srcPic.GetHdc
Dim HDC2 As IntPtr = srcMem.GetHdc
BitBlt(HDC2, 0, 0, rect.Width, rect.Height, HDC1, rect.X, rect.Y,
&HCC0020)
copyRect = srcBmp.Clone()
srcPic.ReleaseHdc(HDC1)
srcPic.ReleaseHdc(HDC2)
srcPic.Dispose()
srcMem.Dispose()
End Function
The following is the calling statment
picZoom.Image = MainDrawPics.makeCopy(picDraw, New RectangleF(0, 0, 50, 50))
Can anyone help me?
My thanks in advanced