Sign in to follow this  
benryves

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

Recommended Posts

benryves    1999
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
benryves    1999
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this