c++-cli CreateBitmapSourceFromMemorySection

0

I am trying to create Bitmap^ from unsigned char* databuffer. I need to do this very effective - this function called many times each second and GUI updated after it runs. My code is :

unsigned char*  databuffer = new unsigned char[_size];
System::IntPtr _intptr = System::IntPtr(databuffer);

System::Windows::Media::Imaging::BitmapSource^ b =
    System::Windows::Interop::Imaging::CreateBitmapSourceFromMemorySection(_intptr, width, height,
    System::Windows::Media::PixelFormats::Bgr32, width, 0);

When last line runs , the exception is thrown : "The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))"

Is there another way to do this ? (I tried to convert the unsigned char* first into Bitmap^ and then into BitmapSource^ but this takes too much time).

Thanks.

bitmap
c++-cli
bitmapsource
asked on Stack Overflow Jan 7, 2015 by Matvey • edited Jan 8, 2015 by Matvey

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0