Is it possible to directly copy bitmap raw data into a texture?

Jan 6, 2015 at 4:53 PM
RendererDX11 class has a function to load texture from memory:
ResourcePtr RendererDX11::LoadTexture( void* pData, SIZE_T sizeInBytes/*, D3DX11_IMAGE_LOAD_INFO* pLoadInfo*/ )
I created a Gdiplus::Bitmap in memory but failed to load it to the texture. My code looks like this:
        using namespace Gdiplus;
    Bitmap bitmap(static_cast<int>(m_DesktopRes.x), static_cast<int>(m_DesktopRes.y));
    Graphics* graphics = Graphics::FromImage(&bitmap);
//// do some drawing with Graphics
//// .....
// load to the texture
    Gdiplus::BitmapData bitmapData;
    Gdiplus::Rect rect(0, 0, bitmap.GetWidth(), bitmap.GetHeight());

    //get the bitmap data
    if (Gdiplus::Ok == bitmap.LockBits(
        //get the lenght of the bitmap data in bytes
        int len = bitmapData.Height * std::abs(bitmapData.Stride);

        m_Texture = Glyph3::RendererDX11::Get()->LoadTexture((void*)bitmapData.Scan0, len);

It fails when WIC try to get a decoder from the data. But since it's raw pixel data that does not need to be decoded (see here), is there a way to work around ? Or what is the correct way to use RendererDX11::LoadTexture() to load from memory?
Jan 9, 2015 at 2:04 AM
I'm not sure how that works to be honest - I added the method at the request of one of the users (you can find the discussion / request here in the discussion forums).

If I had to guess, the bitmap data is probably not in the correct format. Since it is a direct pass through to DirectXTK, I think we could refer to its source code to see what restrictions we would need.