help with byte arrays and pointers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick

    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(Fra meNumber);

    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


  • Truong Hong Thi

    #2
    Re: help with byte arrays and pointers

    >Heres the bit of code:[color=blue]
    >IntPtr pointer = getFrameDll(Fra meNumber);
    >Could someone please teach me how to get byte >arrays from memory using
    >pointers?[/color]
    I think it is imposible. The function should also outputs the array
    length.

    Thi

    Comment

    • Patrick

      #3
      Re: help with byte arrays and pointers

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

      Thanks for the quick reply. (about 4 minutes)




      "Truong Hong Thi" <thi1981@gmail. com> wrote in message
      news:1132289600 .463163.210770@ g49g2000cwa.goo glegroups.com.. .[color=blue][color=green]
      > >Heres the bit of code:
      >>IntPtr pointer = getFrameDll(Fra meNumber);
      >>Could someone please teach me how to get byte >arrays from memory using
      >>pointers?[/color]
      > I think it is imposible. The function should also outputs the array
      > length.
      >
      > Thi
      >[/color]


      Comment

      • Truong Hong Thi

        #4
        Re: help with byte arrays and pointers

        Did you try methods like System.Drawing. Image.FromHBitm ap?

        Comment

        • Truong Hong Thi

          #5
          Re: help with byte arrays and pointers

          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!

          Comment

          • Patrick

            #6
            Re: help with byte arrays and pointers

            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" <thi1981@gmail. com> wrote in message
            news:1132290521 .429952.51170@g 43g2000cwa.goog legroups.com...[color=blue]
            > Did you try methods like System.Drawing. Image.FromHBitm ap?
            >[/color]


            Comment

            • Patrick

              #7
              Re: help with byte arrays and pointers

              Thanks for your time :) Best of luck
              --Patrick
              "Truong Hong Thi" <thi1981@gmail. com> wrote in message
              news:1132291112 .742760.291160@ o13g2000cwo.goo glegroups.com.. .[color=blue]
              >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!
              >[/color]


              Comment

              • Willy Denoyette [MVP]

                #8
                Re: help with byte arrays and pointers


                "Patrick" <patrick@hotmai l.com> wrote in message
                news:O4GovBA7FH A.2628@TK2MSFTN GP11.phx.gbl...[color=blue]
                >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" <thi1981@gmail. com> wrote in message
                > news:1132290521 .429952.51170@g 43g2000cwa.goog legroups.com...[color=green]
                >> Did you try methods like System.Drawing. Image.FromHBitm ap?
                >>[/color]
                >
                >[/color]

                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.


                Comment

                Working...