help with byte arrays and pointers

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

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
 
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
 
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)
 
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!
 
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()?
 
Patrick said:
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 said:
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.
 
Back
Top