Advertisement

Error0x88982f80 : WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT

Started by February 27, 2018 11:20 PM
4 comments, last by MarcusAseth 6 years, 11 months ago

I'm getting the error "WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT" so clearly I'm doing something wrong, I just don't understand what :\

Do you guys see anything wrong in my code?


//Create D3d device, context, swapChain
ID3D11Device* d3dDevice;
ID3D11DeviceContext* d3dContext;
IDXGISwapChain* swapChain;

DXGI_SWAP_CHAIN_DESC swapChainDesc{};
swapChainDesc.BufferDesc.Width = appWidth;
swapChainDesc.BufferDesc.Height = appHeight;
swapChainDesc.BufferDesc.RefreshRate = { 60,1 };
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
swapChainDesc.SampleDesc.Count = 1; // for AntiAliasing
swapChainDesc.SampleDesc.Quality;// for AntiAliasing
swapChainDesc.BufferCount = 2;
swapChainDesc.OutputWindow = appWindow;
swapChainDesc.Windowed = true;


if (HRESULT hr = D3D11CreateDeviceAndSwapChain(nullptr,
					       D3D_DRIVER_TYPE_HARDWARE,
					       nullptr,
					       D3D11_CREATE_DEVICE_BGRA_SUPPORT,
					       nullptr,
					       0,
					       D3D11_SDK_VERSION,
					       &swapChainDesc,
					       &swapChain,
					       &d3dDevice,
					       nullptr,
					       &d3dContext
); hr != S_OK) {
	printError("Error during D3d initialization", hr);
	return 1;
}

//Create D2d factory, renderTarget
ID2D1Factory* d2dFactory;
ID2D1RenderTarget* renderTarget;

if (HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, &d2dFactory); hr != S_OK)
{
	printError("Error during D2d factory creation", hr);
	return 1;
}

//get backBuffer
IDXGISurface* dxgiSurface;
if (HRESULT hr = swapChain->GetBuffer(0, __uuidof(dxgiSurface), reinterpret_cast<void**>(&dxgiSurface)); hr != S_OK)
{
	printError("Error retrieving dxgiSurface", hr);
	return 1;
}

float dpiX, dpiY;
d2dFactory->GetDesktopDpi(&dpiX, &dpiY);

D2D1_RENDER_TARGET_PROPERTIES props{};
props.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
props.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED);
props.dpiX = dpiX;
props.dpiY = dpiY;

if (HRESULT hr = d2dFactory->CreateDxgiSurfaceRenderTarget(dxgiSurface, props, &renderTarget); hr != S_OK)
{
	printError("CreateDxgiSurfaceRenderTarget() function failed", hr);  //THIS FAIL
	system("pause");						    //THIS FAIL
	return 1;						            //THIS FAIL
}

 

I found this page , so if I got it right to get this work I needed to create the device using D3D10.1 and not 11? I tried that and still got the same error...in the end, now I'm using only D2D xD

I kind of don't like this api, there are too many way to get it wrong from what I see... or maybe I am simply not good enough for it x_x

Advertisement

Where is the error occurring? You have several tests, which one the culprit is could be useful

Ok it looks like it's the end of the source with you comments

Try changing both appw/h and dpix/y to 800:600

59 minutes ago, h8CplusplusGuru said:

Try changing both appw/h and dpix/y to 800:600

I can't anymore, I needed to move forward and I thought noone knew, so I got rid of that code, refactored stuff into classes and now I'm using only D2D x_x

Still, if I attempt it in the future one more time, I'll make sure to refer back to this topic and try that as well, thanks

This topic is closed to new replies.

Advertisement