1

I have a problem with using SharpDX. I convert a Bitmap, lock the bits with the lockBits method and then create a DataStream and build a Texture2D from it. This seems to work quite well, no error occurs. Now I have the following problem. I want to convert the Texture2D back to a Bitmap. There is a method called Texture2D.ToStream(size, texture2D, stream) but when I try this only an error occurs. Can anyone help me with this issue? A conversion to an Image or WriteableBitmap would be also okay.

Simon Rühle
  • 229
  • 3
  • 12

1 Answers1

-1

I found a solution:

var inputTex2D = Texture2D.FromStream<Texture2D>(device, inputMemoryStream, (int)inputMemoryStream.Length, new ImageLoadInformation()
        {
            Depth = 1,
            FirstMipLevel = 0,
            MipLevels = 0,
            Usage = ResourceUsage.Default,
            BindFlags = BindFlags.ShaderResource,
            CpuAccessFlags = CpuAccessFlags.None,
            OptionFlags = ResourceOptionFlags.None,
            Format = Format.R8G8B8A8_UNorm,
            Filter = FilterFlags.None,
            MipFilter = FilterFlags.None,
        });

My DirectX Version is 11.0

Simon Rühle
  • 229
  • 3
  • 12