locked
Why the DirectXTK SpriteBatch draw the image not the origin color?

    Question

  • picture 1:

    picture 2:

    I use the picture 1 draw to the canvas , the result is the picture 2.

    but, the 2 pictures colors are not same.

    I want to know, how can I draw the picture with the origin colors on png?

    The follow is my code:

    DX::ThrowIfFailed(
    	CreateWICTextureFromFile(device, L"assets\\wndScene.png", nullptr, m_texture3.ReleaseAndGetAddressOf())
    	);
    
    m_sprites->Begin(SpriteSortMode_Deferred, m_states->AlphaBlend());
    m_sprites->Draw(m_texture3.Get(), XMFLOAT2(0, 0));
    m_sprites->End();

    the code is from 'DirectXTK Windows 8.1 sample'.


    • Edited by lihuipeng49 Monday, December 8, 2014 7:01 PM
    Monday, December 8, 2014 6:45 PM

Answers

All replies

  • It's likely that your wndScene.png is using the sRGB color-space, which DirectX Tool Kit's loader respects if possible.

    If you don't want your sRGB assets to be loaded as a DXGI_FORMAT_*_SRGB format, you can convert that png to an explicitly non-sRGB format and save it as a DDS file using texconv. Then you'd use CreateDDSTextureFromFile.

    DirectXTex & texconv: http://go.microsoft.com/fwlink/?LinkId=248926

    DirectX Tool Kit: http://go.microsoft.com/fwlink/?LinkId=248929

    BTW, read-up on sRGB at http://molecularmusings.wordpress.com/2011/11/21/gamma-correct-rendering/





    Monday, December 8, 2014 7:40 PM
  • I convert my png to dds use the follow command:

    texconv -srgb -f B8G8R8A8_UNORM wndScene.png


    It works good.

    Think you!

    I have another question is that,

    the follow command is failed, it does means the texconv can't do the batch?

    texconv -srgb -f B8G8R8A8_UNORM *.png


    I want convert the all the png in directory 1 to dds,

    and output them to the directory 2.

    One more question,

    when I convert the png to dds, I found the file size from 1MB to 21MB.

    Is there has some dds format like the png can compress the image with no color lost?
    • Edited by lihuipeng49 Tuesday, December 9, 2014 4:54 PM
    Tuesday, December 9, 2014 5:21 AM
  • texconv doesn't currently support wildcards, but you could use a for batch statement easily enough. You can use -o to set the output directory. See the DirectXTex wiki for more details.

    You should consider using BC1_UNORM, BC2_UNORM, or BC3_UNORM (depending on your alpha content). See this post for some details.

    Tuesday, December 9, 2014 8:22 PM