locked
How to obtain ID3D11Texture2D for XAML image?

    Question

  • I'm developing a XAML app that interops with D3D to display images with applied effects. I can make a XAML image object (Image or ImageBrush) accessible to the C++/DX code, but I don't know how to obtain a ID3D11Texture2D interface for the image. Can someone tell me how this is done?
    Monday, September 17, 2012 9:33 PM

Answers

  • Hi Bob,

    You cannot get the pixel data out of an arbitrary Image object. The exception is the one you've found: if the ImageSource is a WriteableBitmap then you can access its PixelBuffer. For any other ImageSource you will need to keep track of the data's source and reuse that rather than getting the pixels directly from the Image.

    --Rob

    • Marked as answer by Bob Flora Wednesday, September 19, 2012 2:41 PM
    Tuesday, September 18, 2012 6:41 PM
    Owner

All replies

  • Thanks, Lloyd. Actually, I'm already using SurfaceImageSource to interop C#/XAML with C++/D3D. SurfaceImageSource is a means of presenting a D3D rendered surface as an image to C#, but I need to send an image in the other direction (i.e., C# side to D3D side).

    For now, I'm going to use a WriteableBitmap to pull the pixel data out of the image and then copy it to the D3D texture byte by byte. If anyone knows of a more elegant solution please let me know.

    Tuesday, September 18, 2012 1:43 PM
  • Hi Bob,

    You cannot get the pixel data out of an arbitrary Image object. The exception is the one you've found: if the ImageSource is a WriteableBitmap then you can access its PixelBuffer. For any other ImageSource you will need to keep track of the data's source and reuse that rather than getting the pixels directly from the Image.

    --Rob

    • Marked as answer by Bob Flora Wednesday, September 19, 2012 2:41 PM
    Tuesday, September 18, 2012 6:41 PM
    Owner
  • Thanks for the confirmation, Rob.
    Wednesday, September 19, 2012 2:41 PM