Ask Your Question

Revision history [back]

OpenCV Mat to Id2d1Bitmap

I have to render opencv Mat to using DirectX 11.

D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1( D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE), 96, 96 ); D2D1_SIZE_U s = D2D1::SizeU(640, 480); hr = m_d2DeviceContext->CreateBitmap(s, bitmapProp, &m_streamBitmap); I have to copy opencv matrix to m_streamBitmap. pImage is a color image with 3 channels.

m_streamBitmap->CopyFromMemory(NULL, reinterpret_cast<byte*>(pImage.data),pImage.cols()*3); This gives distorted image as result. Can anyone guide me with this.

Thanks in advance .

OpenCV Mat to Id2d1Bitmap

I have to render opencv Mat to using DirectX 11.

D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1(
D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW,
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE),
96,
96
);
D2D1_SIZE_U s = D2D1::SizeU(640, 480);
hr = m_d2DeviceContext->CreateBitmap(s, bitmapProp, &m_streamBitmap);

I have to copy opencv matrix to m_streamBitmap. pImage is a color image with 3 channels.

m_streamBitmap->CopyFromMemory(NULL, reinterpret_cast<BYTE*>(pImage.data),pImage.cols()*3);

m_streamBitmap->CopyFromMemory(NULL, reinterpret_cast<byte*>(pImage.data),pImage.cols()*3); This gives distorted image as result. Can anyone guide me with this.

Thanks in advance .