Convert array<Byte>^ data to const byte* data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Happy2006
    New Member
    • Feb 2010
    • 1

    Convert array<Byte>^ data to const byte* data

    Hello

    I am trying to call a function in C from C# though c ++

    so basically C# -> C++ - >C

    In C#, I have byte[] bytes - which reads the information from the file. I am passing the byte array and the size to C++ .

    In C++ I get the byte array and the size but I am not able to convert to the specific data types.

    Code:
    void Image::OpenMemFile(array<Byte>^ data, unsigned int size)
    {
    
    	Free();
    	m_dataStream = data;
    	[B]Byte const* streamData = &data[0];[/B]   // this is where it throws error 
             // Should I use marshaling here ? What call should that be ?
             hImage = ::OpenMemImage(streamData , size);
    	modified = false;
    }
    
    // this is the function I need to call 
    EXIVSIMPLE_API HIMAGE OpenMemImage([B]const BYTE *data[/B], unsigned int size)
    {
       // code
    	    imgWrap->image = Exiv2::ImageFactory::open(data, size);
    
    }
    the C function it needs to call is
    Code:
    Image::AutoPtr ImageFactory::open(const byte* data, long size)
        {
          /// code
        }
    I need to help in converting the byte array to const byte* . I realize I need to use Marshaling. Is there a specific function to marshal arrays in C++ ?

    Any help is appreciated.

    Thanks
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Moved to .NET because this is not C++ but C++/CLR, marshalling is part of the .NET framework

    Comment

    Working...