473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

bitblt

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
Sep 22 '07 #1
5 3199
"Ricardo Furtado" <Ri************@discussions.microsoft.comschrieb
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

Sep 22 '07 #2
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

"Armin Zingler" wrote:
"Ricardo Furtado" <Ri************@discussions.microsoft.comschrieb
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

Sep 24 '07 #3
"Ricardo Furtado" <Ri************@discussions.microsoft.comschrieb
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
Sep 24 '07 #4
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
"Armin Zingler" wrote:
"Ricardo Furtado" <Ri************@discussions.microsoft.comschrieb
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
Sep 24 '07 #5
"Ricardo Furtado" <Ri************@discussions.microsoft.comschrieb
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
>
Thanks

Ricardo Furtado
"Armin Zingler" wrote:
"Ricardo Furtado" <Ri************@discussions.microsoft.com>
schrieb
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
Sep 24 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DraguVaso | last post by:
Hi, In the override of the Paint-method of a DataGridTextBoxColumn I want to show an image with BitBlt, to see what I can gain there on performance. The problem is: It doesn't show me the image...
5
by: JackS | last post by:
I am trying to use GDI32 bitblt to write a bitmap to a control's window, but all I get is an empty rectangle of some rop-dependent color. In short, I use the following logic in a paint event handler:...
7
by: VB Programmer | last post by:
I am using the BitBlt operation to capture various controls into jpegs. It's almost like a screen capture, but of just the control. (This is a VB.NET application.) Because of BitBlt limitations...
6
by: Larry Serflaten | last post by:
Can anyone see something wrong with the code below? Friend Sub MapUpdate(ByRef Artwork As Bitmap, ByRef Player As MapObject) If grxForm Is Nothing Then grxForm = Me.CreateGraphics Dim hdcDst...
7
by: matt | last post by:
Hallo, I have to create a simple sprite movement; in VB6 I used the API BitBlt and all was very good. Using the NET graphical methods (not API) , the result is slow. Do you have a NET...
3
by: fripper | last post by:
Is there a way to use the windows bitblt function in a VB 2005 app? bitblt requires device context parameters for the source and destination controls but those are not used in VB 2005. Is there...
6
by: Martijn Mulder | last post by:
/* BitBlt.cs C# code using P/Invoke I have good reasons to use P/Invoke to get access to the Win32 API function BitBlt(). But I have trouble understanding the workings of it. Below is a...
1
by: =?Utf-8?B?Y3JhbmtlX2JveQ==?= | last post by:
Hi Folks, I'm not sure where this post belongs since I'm using managed vc.net, but the issue is around GDI BitBlt. Here is a summary of the problem: - I am trying to copy a bitmap of my main...
0
by: crankeboy | last post by:
Hi Folks, My setup: Visual Studio Express 2008, VC++, .NET, BitBlt Here is a summary of the problem: - I am trying to copy a bitmap of my main form into a picture box. - To do this, I bitblt...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.