Hi
I am trying to Offscreen Render to a Direct2D surface using CEF3. Th eOnPaint call gets fired and I can save the buffer to a hHitmap but I'm not having much look getting the buffer to a D2D1Bitmap. Here is what I have but it doesn't work (blank output to the direct2d surface). The pixel format could be wrong or any of the direct2d stuff. Direct2D is a bit new for me.
void RenderHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height)
{
//SaveBrowserImage(browser, L"C:\\Temp\\MyTest.bmp", buffer, width, height);
ID2D1Bitmap * pBitmap = NULL;
D2D1_PIXEL_FORMAT desc2D = D2D1::PixelFormat();
desc2D.format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc2D.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
D2D1_BITMAP_PROPERTIES bmpProperties = D2D1::BitmapProperties();
bmpProperties.dpiX = 96.0f;
bmpProperties.dpiY = 96.0f;
bmpProperties.pixelFormat = desc2D;
D2D1_RECT_F rect = D2D1::RectF(0.0,0.0,width, height);
D2D1_SIZE_U size = D2D1::SizeU(width, height);
HRESULT hr = m_pRenderTarget->CreateBitmap(size, bmpProperties, &pBitmap);
if (hr == S_OK && pBitmap)
{
hr = pBitmap->CopyFromMemory(NULL, buffer, width * 4);
if (hr == S_OK)
{
m_pRenderTarget->DrawBitmap(pBitmap, rect);
}
pBitmap->Release();
}
}
Thanks