REspawn

Hi,

Is it possible to lock a texture at a certain level and then write its data out to a BinaryWriter

Thanks for any help,

-Dave



Re: Game Technologies: Graphics Lock texture level and write data to stream

Wessam Bahnassi

Yes. Basically lock the texture, read the data from the GraphicsStream and write it to your BinaryWriter.




Re: Game Technologies: Graphics Lock texture level and write data to stream

REspawn

Any clue or point in the right direction of how i can do this

I have been expermenting with the graphics stream and the binary writer but with no luck so anything you can tell me would be excellent.

Thanks,

-Dave





Re: Game Technologies: Graphics Lock texture level and write data to stream

Wessam Bahnassi

What is it exactly that's failing in your case




Re: Game Technologies: Graphics Lock texture level and write data to stream

REspawn

Nothings failing yet, im trying to figure out how i can take the raw RGBA data from a graphics stream and write it using the BinaryWriter.



Re: Game Technologies: Graphics Lock texture level and write data to stream

Wessam Bahnassi

A GraphicsStream is just inherited from the .NET Stream class, so you deal with it just the same way (call Read()). The data you read can then be given directly to the BinaryWriter.Write() method...




Re: Game Technologies: Graphics Lock texture level and write data to stream

REspawn

Excellent i see what you mean now. I have been working on it and when i try and write the data from one stream to the other i run into an access violation error.

The streams length is huge, just for a simple 256x256 dxt1 texture with no mipmaps. Its length is coming in as 2147483647.

Heres the code im using...

BinaryWriter bw = new BinaryWriter(File.Create(file));

gs = texturesIdea.TextureImage.LockRectangle(0, LockFlags.None);

byte[] chunk = new byte[gs.Length];

gs.Read(chunk, 0, gs.Length);

bw.Write(chunk);

Is there a better way of doing this, the length of the stream cant be that long so im doing something wrong somewhere along the line.

Thanks for the help Wessam.





Re: Game Technologies: Graphics Lock texture level and write data to stream

Wessam Bahnassi

A 256x256 DXT1 with no mipmaps is 32768 bytes only. 2147483647 is 0x7FFFFFFF which is obviously not a valid length for such a 3D texture. Are you sure that all your textures are properly read/created




Re: Game Technologies: Graphics Lock texture level and write data to stream

REspawn

Yea its reading perfect and works fine when rendering, the byte position i get the error is at 32768 so it must be coming in right.