Skip to main content
gamedev.net
🔒 Locked

TextureLoader.FromStream

Started by Lord_Taren Apr 6, 2005 at 10:47 AM 1 replies 1.1k views
Original Post
Lord_Taren
Lord_Taren
I am having a problem creating a 3D Texture from a Memory Stream. Here is what I am doing. //* xTmpImage is initilized and loads a bmp file elsewhere System.Drawing.Bitmap xTmpImage xImageStream = new System.IO.MemoryStream(); xTmpImage.Save( xImageStream, ImageFormat.Bmp ); xTmpTexture = TextureLoader.FromStream( GrafixEnv.Device, xImageStream, xImageStream.Length); When the FromStream function executes I get the following errors ManagedDX: The HRESULT 0x88760b59 was returned (D3DXERR_INVALIDDATA). Please turn on unmanaged debugging for more information. An unhandled exception of type 'Microsoft.DirectX.Direct3D.InvalidDataException' occurred in microsoft.directx.direct3dx.dll Additional information: Error in the application. I have double checked all of the parameters and they are all initilied and valid. When I try to create the texture from a file it works ok. The only thing that I can think of is the BMP file written to the memory stream is somehow missing some data. Thanx in advance for the help.
-------------------Emil Diegoediego@miami.edu
turnpast
turnpast
What you are doing looks okish. Don't know why its beraking. If I were in your place I would just use the Texture constructor that takes a bitmap as a parameter.

If you are set on using a stream the way you are you may have to seek the beginning of the stream (using Seek() or Position = 0) when you are done writing it and before you start reading from it.

Lord_Taren
Lord_Taren
That was it. I needed to manually set the stream position to 0 before creating the texture. Once I did that, everything worked ok.
-------------------Emil Diegoediego@miami.edu

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.