bitblt

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
 
A

Armin Zingler

Ricardo Furtado said:
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."

I haven't had a close look at the code yet because the main thing is
missing: Your declaration of BitBlt.


Armin
 
G

Guest

Thank you for you answer and interest.

the declaration is this

Public Declare 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

I've looked at it and seems like the parameters correspond to the ones
beeing called.

Best Regards

Ricardo Furtado
 
A

Armin Zingler

Ricardo Furtado said:
Thank you for you answer and interest.

the declaration is this

Public Declare 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

I've looked at it and seems like the parameters correspond to the
ones beeing called.

This is the declaration for VB6.


Armin
 
G

Guest

I didnt knew there was another declaration for vb .net. I usually dont use
the API functions in vb .net.
Can you tell me what the declaraction is for .Net or give me the reference
for a web site that has it?

Thanks

Ricardo Furtado
 
A

Armin Zingler

Ricardo Furtado said:
I didnt knew there was another declaration for vb .net. I usually
dont use the API functions in vb .net.
Can you tell me what the declaraction is for .Net or give me the
reference for a web site that has it?

In the help index, type Bitblt. You get the declaration for C. Just
translate the data types.

This should work:

Public Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As
Intptr, ByVal x As integer, ByVal y As integer, ByVal nWidth As
integer, ByVal nHeight
As integer, ByVal hSrcDC As intptr, ByVal xSrc As integer, ByVal ySrc As
integer, ByVal
dwRop As integer) As boolean

There's also www.pinvoke.net

Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top