SharpDX Compatibility - System.Drawing

Is it possible to get something drawn using the default .net paint methods (System.Drawing methods) for a SharpDX Texture2D object so that I can display it as a texture? Preferably using SharpDX tools.

If so, how?

edit: what I'm trying so far:

Bitmap b = new Bitmap(100,100); MemoryStream ms = new MemoryStream(); b.Save(ms, System.Drawing.Imaging.ImageFormat.Png); Texture2D tex = Texture2D.Load(g.device, ms); // crashing here ms.Close(); 
+6
source share
1 answer
  b.Save(ms, System.Drawing.Imaging.ImageFormat.Png); Texture2D tex = Texture2D.Load(g.device, ms); 

Calling Save () leaves the memory stream located at the end of the stream. This will conflict with the Load () method, it will not be able to read data from the stream. You will have to rewind the thread explicitly. Insert this statement between two lines of code:

  ms.Position = 0; 
+5
source

Source: https://habr.com/ru/post/959482/


All Articles