Advertisement Jump to content
Sign in to follow this  
kgstation

NEED HELP!create_async() failed problem!

This topic is 1824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using create_async to load bitmap.

This works fine under release mode, but failed in debug mode.

Following is my code

Concurrency::create_async([&]()
{
mBackGround = new YHMSprite(mDeviceResources, L"Textures\\Menu\\background.png");
});

YHMSprite::YHMSprite(shared_ptr<DX::DeviceResources> &deviceResources, LPCWSTR fileName)
{
	mDeviceResources = deviceResources;
	ComPtr<IWICBitmapDecoder> wicBitmapDecoder;
	mDeviceResources->GetWicImagingFactory()->CreateDecoderFromFilename(fileName, nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &wicBitmapDecoder);
	ComPtr<IWICBitmapFrameDecode> wicBitmapFrame;
	wicBitmapDecoder->GetFrame(0, &wicBitmapFrame);
	ComPtr<IWICFormatConverter> wicFormatConverter;
	mDeviceResources->GetWicImagingFactory()->CreateFormatConverter(&wicFormatConverter);
	wicFormatConverter->Initialize(wicBitmapFrame.Get(), GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nullptr, 0.0, WICBitmapPaletteTypeCustom);
	double DpiX = 96.0f, DpiY = 96.0f;
	wicFormatConverter->GetResolution(&DpiX, &DpiY);
	mDeviceResources->GetD2DDeviceContext()->CreateBitmapFromWicBitmap(wicFormatConverter.Get(), BitmapProperties(PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), static_cast<float>(DpiX), static_cast<float>(DpiY)), &mBitmap);
	mBitmapSize = mBitmap->GetSize();
	mDeviceResources->GetD2DFactory()->CreateDrawingStateBlock(&mStateBlock);
}

I don't know what's wrong with it.

My program triggered a breakpoint under debug mode.

 

Any help would be appreciated!

 

Share this post


Link to post
Share on other sites
Advertisement
Exactly in which line was the break point triggered? I assume it was triggered because an assert failed? Which assert failed?

Share this post


Link to post
Share on other sites

Exactly in which line was the break point triggered? I assume it was triggered because an assert failed? Which assert failed?

Triggered in this line 

mDeviceResources->GetD2DDeviceContext()->CreateBitmapFromWicBitmap(wicFormatConverter.Get(), BitmapProperties(PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), static_cast<float>(DpiX), static_cast<float>(DpiY)), &mBitmap);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!