3
votes

Does anyone know if it is possible in XNA to dynamically load bitmap from jpg files and draw texture2d using other surface formats then SurfaceFormat.Color?

Because of memory/speed limits I need to use Bgr565 or Dxt surface formats. I could use content pipeline and set Content Processor, Texture Format to DxtCompressed but Content.Load doesn't allow dynamic texture load.

I could use Texture2D.FromStream but it creates SurfaceFormat.Color texture only. I experiment with creating empty Texture2D in desired surface format and try to manualy set bitmap data using SetData but it seems like a too complicated way.

Is there Texture2D.FromStream and Texture2D.SetData the only way to dynamically load jpg files and use them as Bgr565 or Dxt surface format textures?

1

1 Answers

1
votes

Haven't got a solution for loading with SurfaceFormat. But you can load them and draw them to a rendertarget with the desired format, then copy the textureData to a new texture you create with the required format?

Will increase loading-times, but should allow the sped-up execution you are looking for?