473,466 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

help with byte arrays and pointers

I've search for hours on this problem and cannot find a solution :(

Heres the bit of code:
IntPtr pointer = getFrameDll(FrameNumber);

The pointer points to a byte[] array that represents a bitmap.

I do not know the length of the array and Marshal.SizeOf() returns 4 bytes
(32 bit integer)

for the size of the pointer.

Could someone please teach me how to get byte arrays from memory using
pointers?

Gratefully,

Patrick
Nov 18 '05 #1
7 1456
>Heres the bit of code:
IntPtr pointer = getFrameDll(FrameNumber);
Could someone please teach me how to get byte >arrays from memory using
pointers?

I think it is imposible. The function should also outputs the array
length.

Thi

Nov 18 '05 #2
I was afraid of that. It's all a learning lesson :)
BTW, trying to convert this line from Delphi to C#
function getFrameDll(frame: integer): PByteArray; cdecl; external
'vidframe.dll' name '?getFrame@@YAPAEH@Z';

Thanks for the quick reply. (about 4 minutes)


"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Heres the bit of code:
IntPtr pointer = getFrameDll(FrameNumber);
Could someone please teach me how to get byte >arrays from memory using
pointers?

I think it is imposible. The function should also outputs the array
length.

Thi

Nov 18 '05 #3
Did you try methods like System.Drawing.Image.FromHBitmap?

Nov 18 '05 #4
I just had a look at System.Drawing namespace documentation and see
that the Bitmap constructor also accepts IntPtr and additional params.
Hope it works!

Nov 18 '05 #5
I just tried it. "A generic error occurred in GDI+". Does csharp have
something similar to a PByteArray ? Or is there a way to say the equivelant:
public static extern byte[]* foo()?

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Did you try methods like System.Drawing.Image.FromHBitmap?

Nov 18 '05 #6
Thanks for your time :) Best of luck
--Patrick
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I just had a look at System.Drawing namespace documentation and see
that the Bitmap constructor also accepts IntPtr and additional params.
Hope it works!

Nov 18 '05 #7

"Patrick" <pa*****@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
I just tried it. "A generic error occurred in GDI+". Does csharp have
something similar to a PByteArray ? Or is there a way to say the
equivelant: public static extern byte[]* foo()?

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Did you try methods like System.Drawing.Image.FromHBitmap?



Yes, it has it's the IntPtr retuned , but if you don't know the length of
the byte[] pointed to by the returned poiner, how are you going to handle
the array contents?
Isn't it possible that the frame has a fixed lentgh? How do you manage this
in Delphi?

Willy.
Nov 18 '05 #8

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

Similar topics

8
by: Tom Bean | last post by:
I have several data files containing ASCII strings, int, long and byte data types and need to store the data in variables of the appropriate type. From previous posts, there seem to be several...
3
by: Ted Miller | last post by:
Hi folks, I've got an unmanaged routine I'm pinvoking to. It takes a pointer to an array of 3 pointers to bytes, typed as byte**. public static extern void foo(byte **p3pb); unsafe {...
12
by: Olaf Baeyens | last post by:
I am porting some of my buffer class code for C++ to C#. This C++ class allocates a block of memory using m_pBuffer=new BYTE; But since the class is also used for pointers for funtions that uses...
4
by: kelli | last post by:
i am new to c# so if this is a trivial problem, forgive me! i've searched the web and after 2 days still cannot solve it. i am converting a c++ application to c# - the problem code is listed...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
5
by: Oleg Subachev | last post by:
Is there other way of comparing two byte arrays than iterating through the two and compare individual bytes ? Oleg Subachev
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
24
by: ThunderMusic | last post by:
Hi, The subject says it all... I want to use a byte and use it as byte* so I can increment the pointer to iterate through it. What is the fastest way of doing so in C#? Thanks ThunderMusic
3
by: dupuis2387 | last post by:
Hi, I'm having trouble getting an activeXDLL component that I created to work in asp. It works fine in a VB6 windows app, but for some reason, it won't work in my asp page. I compiled the dll,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.