473,499 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting returned IntPtr to Struct or Reference type

Gaz
Hi all,

I'm using a 3rd party Assembly that contains a method which returns
bitmap data, however the Return value type is IntPtr and I need to
convert it so I can access the Bitmap data:

I'm trying to use a Callback function:

public delegate My_RETURN STATE_CALLBACK(
IntPtr GuiStateCallbackCtx,
BioAPI_GUI_STATE GuiState,
BioAPI_GUI_RESPONSE Response,
BioAPI_GUI_MESSAGE Message,
BioAPI_GUI_PROGRESS Progress,
IntPtr SampleBuffer);

I can use this method and the CallBack function is executed but I'm
stuck as to how to convert the returned Samplebuffer IntPtr into the
GUI_BITMAP structures defined as below:

public class GUI_BITMAP
{
public uint Width;
public uint Height;
public GUI_DATA Bitmap;
}

public class GUI_DATA
{
public uint Length = 0;
public byte[] Data = null;
}

I'm very new to using C# having come from a Delphi background and am
struggling with converting/casting Pointer types to meaningful
structures.

If anyone could give me any help on this it would be much appreciated!

Thanks for your time,

Gareth
Nov 15 '05 #1
1 5048
Gareth,

Have a look at the System.Runtime.InteropServices.Marshal class,
especially its PtrToStructure and Copy methods.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2

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

Similar topics

1
6082
by: BestNews | last post by:
Hi all, how to cast an System.IntPtr value to struct type. Example: protected override void WndProc(ref System.Windows.Forms.Message m) { const int WM_WINDOWPOSCHANGED = 0x0047;
9
2801
by: Angel | last post by:
Hi again, I'm trying to call functions from a proprietary DLL but it's turned out to be more difficult than I thought. I have this W32.DLL which was written in C by USPS. They don't provide the...
8
4531
by: iyuen | last post by:
I'm having problems with converting a byte array to an image object~ My byte array is an picture in VB6 StdPicture format. I've used propertybag to convert the picture into base64Array format in...
1
8678
by: Jan Nielsen | last post by:
In a C# application I'm using the NetShareGetInfo API function to get some information about a share. This is working all right. Now I want my application to be able to display the contents of...
5
3839
by: Rob Panosh | last post by:
Could somebody please assist me in converting the following C#.Net code to VB.Net code? private static extern short SQLAllocHandle(short hType, IntPtr inputHandle, out IntPtr outputHandle); ...
9
5648
by: Hugo Amselschlag | last post by:
Hi there, I've implemented a local system hook to suppress certain windows beeing displayed by the axWebbrowser control. Now I need some more information before I can decide, whether to suppress...
27
3146
by: Eric | last post by:
Hi all, I have a C++ application that load C# applets. A method use an IntPtr parameter because I want to be 32/64-bit compatible. The problem is in the .tlh file generated. This parameter is...
1
2565
by: DaTurk | last post by:
I'm having an issue converting an unmanaged struct to a CLI managed struct. It's a value struct and this cannot be changed. public value struct UpdateItem { public: System::String ...
0
2097
by: Charming12 | last post by:
Hi All, I have a strange problem and due to my inefficiency with IntPtr i am unable to figure it out. I have an structure something like: public struct Detail { public int age; public...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.