You don't exacly understand me. I have that code:
IDWriteBitmapRenderTarget *pRenderTarget;
hResult = pGDIInterop->CreateBitmapRenderTarget(
NULL,
m_renderTargetWidth,
m_renderTargetHeight,
&pRenderTarget
);
if (FAILED(hResult)) {
m_lastError = L"Failed to create bitmap render target";
}
else {
hResult = pRenderTarget->SetPixelsPerDip(1.0f);
hResult = S_OK;
HDC hDC = pRenderTarget->GetMemoryDC();
if (hDC == NULL) {
m_lastError = L"Failed to get render target DC";
hResult = E_FAIL;
}
else {
HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0));
if (hBrush == NULL) {
m_lastError = L"Failed to create brush";
hResult = E_FAIL;
}
else {
HBITMAP hBitmap = static_cast<HBITMAP>(GetCurrentObject(hDC, OBJ_BITMAP));
if (hBitmap == NULL) {
m_lastError = L"GetCurrentObject failed";
hResult = E_FAIL;
}
else {
DIBSECTION dib;
int iResult = GetObject(hBitmap, sizeof(dib), &dib);
if (iResult < sizeof(dib)) {
m_lastError = L"GetObject failed";
hResult = E_FAIL;
}
else {
// Store render target resources and info
m_pRenderTarget = pRenderTarget;
m_hDC = hDC;
m_hBlackBrush = hBrush;
m_bmBits = dib.dsBm.bmBits;
m_bmWidthBytes = static_cast<UINT>(dib.dsBm.bmWidthBytes);
m_bmBytesPixel = static_cast<UINT>(dib.dsBm.bmBitsPixel) / 8;
hResult = S_OK;
}
}
if (FAILED(hResult))
DeleteObject(hBrush);
}
}
if (FAILED(hResult))
pRenderTarget->Release();
}
pGDIInterop->Release();
The API of my project didn't allow me to use functions: CreateSolidBrush, GetCurrentObject and GetObject. With solid brush I don't have a problem, because in directX i had a functions, that allow me to do it, but with the two others, I havea problem, because I cannot use it, so I cannot get a BITMAP structure, so I don't have a value for bmBits, bmWidthBytes and bmBitsPixel. I must get this values, so is there another way to get it?