• Advertisement
Sign in to follow this  

[MDX] Texture.FromBitmap - slow and sometimes gets it wrong.

This topic is 4365 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I decided to have a look into Managed DirectX, and so far it's been pretty plain sailing. One issue I've been having is the Texture.FromBitmap() method. It's taking up to a minute per Bitmap; I'm passing Usage.None and Pool.Managed as parameters. Other combinations tend to fail. Not only is it incredibly slow, but some textures appear to only decode the top row (so the final result is that the wall is made up of lots of vertical stripes, one per pixel column on the original image). My workaround is to create a new MemoryStream, to use the Bitmap.Save() method to save it to the stream, to reset the position in the stream with Stream.Seek then to use the TextureLoader.FromStream() method to load it again. This takes under a second to load all the textures (DOOM is hardly a resource hog) but it seems a little... hacky. I'm using the Bitmap class as it seemed the best generic class to store bitmap data in in my DOOM.Wad class. Being an (almost) complete DirectX beginner, I doubt I've given anywhere near enough information; judging by other posts on other websites it seems to be more linked to the slowness of the Bitmap class. Is this the case? Is there a better, cleaner way to load a Texture from a Bitmap?

Share this post


Link to post
Share on other sites
Advertisement
Hmm, it seems to be related to debugging; but I get the same abysmal speeds whether I run the debug or release mode (just running the EXE). Thanks, though. I'll stick to my hacky method for the moment, as it's fast enough and small.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement