Creating a texture in DX and setting that to a BitMapImage RRS feed

  • Question

  • I have a C++ metro app that, when a button is clicked, can update the source of a XAML image block.

    void ImageDisplay::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    	BitmapImage^ defaultCover = ref new BitmapImage( ref new Uri( "ms-appx:///Assets//image.png"));
    	Image1->Source = defaultCover;

    This works great for an image that has already been loaded as an asset. What if I want to dynamically create a directX texture, and have that be displayed as my image source? I want to create a texture like this:

    // Now create the direct3d texture object 
    ID3D11Texture2D *dx_texture = nullptr; 
    HRESULT hr = dx_device->CreateTexture2D( &desc, NULL, &dx_texture );

    I want to then manipulate this texture in directX, and when I'm done, set it as the source to my Image1 above. How would I go about doing this?


    Monday, August 6, 2012 9:49 PM


All replies