I've 4 image byte array with the same resolution 640*480. I'm trying to copy the byte array data from memory if the D2D1Bitmap is already available. After copying, d2dContext.DrawBitmap(bitmap) method fails, Here is the code,
Any pointers on what I'm missing?
if (bitmap == nullptr)
{
hr = m_d2dContext->CreateBitmap(D2D1::SizeU(width, height),
buffer->Data,
width * 4,
//(width * height) / 2 * 3,
D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE)),
//D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_NV12,D2D1_ALPHA_MODE_IGNORE)),
&bitmap);
if (FAILED(hr))
{
return;
}
}
else
{
D2D1_SIZE_F rtSize = m_d2dTargetBitmap->GetSize();
D2D1_RECT_U rect = D2D1::RectU(
0,
0,
rtSize.width,
rtSize.height
);
hr = bitmap->CopyFromMemory(&rect , buffer->Data, width * 4);
}
m_d2dContext->BeginDraw();
m_d2dContext->DrawBitmap(bitmap);
//bitmap->Release();
hr = m_d2dContext->EndDraw();