How to save ID2D1Bitmap to PNG file

懵懂的女人 提交于 2019-11-28 02:04:22

How would you even know if you had an error, since you just swallow errors and continue instead of logging where they came from? You get a non-zero hresult, so first figure out which function it comes from by adding a printf or fprintf after every single function call. And you have a glaring omission in the block:

if (SUCCEEDED(hr))
{
    //
    // Render into the bitmap
    //
    pRT->BeginDraw();

pRT->Clear(D2D1::ColorF(D2D1::ColorF::White));


pRT->DrawBitmap(pBitmap);

    pRT->EndDraw();
}
if (SUCCEEDED(hr))

You don't bother to assign hr anywhere in there, so you wouldn't even know if any of them are erroring out. Obviously, Clear() and the final png writing work fine, since you get a good file, so it's DrawBitmap or one of the bitmap creation calls that are failing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!