转换数组<;字节>;^数据到常量字节*data-C++/CLR
我试图从C#尽管是C#调用C中的函数++ <> P>基本上C→-> C++ +> C<P> 在C#中,我有byte[]字节,它从文件中读取信息。我把字节数组和大小传递给C++。 在C++中,我得到字节数组和大小,但是我不能转换到特定的数据类型。转换数组<;字节>;^数据到常量字节*data-C++/CLR,clr,marshalling,bytearray,Clr,Marshalling,Bytearray,我试图从C#尽管是C#调用C中的函数++ P>基本上C→-> C++ +> C<P> 在C#中,我有byte[]字节,它从文件中读取信息。我把字节数组和大小传递给C++。 在C++中,我得到字节数组和大小,但是我不能转换到特定的数据类型。 void Image::OpenMemFile(array<Byte>^ data, unsigned int size) { Free(); m_dataStream = data; Byte const* strea
void Image::OpenMemFile(array<Byte>^ data, unsigned int size)
{
Free();
m_dataStream = data;
Byte const* streamData = &data[0]; // 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(const BYTE *data, unsigned int size)
{
// code
imgWrap->image = Exiv2::ImageFactory::open(data, size);
}
我需要帮助将字节数组转换为常量字节*。我意识到我需要使用编组。C++中是否有特定的函数排列数组?< /p>
感谢您的帮助
谢谢pin_ptr pin_buffer=&data[0];
pin_ptr<unsigned char> pin_buffer = &data[0];
unsigned char* pData = pin_buffer;
无符号字符*pData=pin_缓冲区;
pin_ptr<unsigned char> pin_buffer = &data[0];
unsigned char* pData = pin_buffer;