Notifications
Clear all

[Closed] Reading textures

I have a question about reading textures from a file.
Say I have a custom texture format that i want to use for a game.
The format is a dds dxt5 texture for instance.
Is there a way to directly apply texture data to a model file in max or do i need to create a dds texture then apply it.
Also if i need to do the second method is there a faster way to read large amounts of data
other then something like
for i = 1 to filebytecount do (
writebyte (readbyte fstream) ddsfile
)
i am thinking there must be a way to copy and paste large amounts of data besides readbyte and writebyte.
thanks so much for any help or tips

5 Replies
 lo1

Regarding your second question:

(dotNetClass "System.IO.File").ReadAllBytes "C:\\yourfile.dat"

Cool could you show me an example in .net of reading say 1000 bytes from one file then writing that out to a new file.

 lo1

I think it depends, really. If you are reading the first 1000 bytes from a 1200 byte file, I would use the code above, afterwards truncate the resulting array to 1000 members, and use that array in this command:

(dotNetClass "System.IO.File").WriteAllBytes "C:\\yourpath.dat" theArray

On the other hand, if you are only reading a small percentage of the file, you might want to read only the necessary bytes in a loop.

I am wanting to read the custom header say 40 bytes then read a section of the file say 1000 bytes then there is other data before and after these sections is there a parameter i add to the read all bytes to just get that part?

I will try to implement this example here thanks for your help.

http://msdn.microsoft.com/en-us/library/system.io.filestream.read.aspx

 lo1

AFAIK, There is no overload for ReadAllBytes to read only some bytes.

Using a FileStream is most likely the best solution for your intentions.