Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert BYTE* to Array<byte>^

Tags:

c++-cx

Is it possible to convert byte* to Array^ in C++/CX?

Currently I accomplish this by copying each value, which I know is not space/performance efficient.

My current implementation is :

Array<byte>^ arr = ref new Array<byte>(byteCount);
for (int i = 0; i < byteCount; i++)
{
    arr[i] = *(bytes + i);
}
like image 742
Arctic Avatar asked Jun 01 '14 12:06

Arctic


1 Answers

There's an array constructor for that (MSDN): Array(T* data, unsigned int size);

So in your case, simply do: Array<byte>^ arr = ref new Array<byte>(bytes, byteCount);

This is a great article on C++/CX and WinRT array patterns.

like image 91
Andy Rich Avatar answered Sep 29 '22 07:09

Andy Rich