1
votes

How do I access the data in a Texture2D object? Lots of XNA posts suggest using the function Texture2D.GetData but that appears to be missing in the SlimDX version of a Texture2D. I need to process my image to calculate overall luminance of the scene and don't want to be running 300 accesses in a pixel shader (i.e. 300 access * num_pixels per frame) when I could be doing it once per frame.

All I need to be able to do is access the colour (R32G32B32A32) of the texture.

Ah I reckon I've found it thanks to the SlimDX SDK. The Texture2D.ToStream() method sends the texture data to a memory stream, then I simply have to parse the bytes to get at my data. I'll submit this as an answer if it works for me.

1

1 Answers

1
votes

Yep, ToStream() works fine, thanks to the SlimDX SDK. The Texture2D.ToStream() method sends the texture data to a memory stream, then I simply have to parse the bytes to get at my data.