View Full Version : Reading textures
06 June 2011, 04:12 PM
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 :)
Regarding your second question:
(dotNetClass "System.IO.File").ReadAllBytes "C:\\yourfile.dat"
06 June 2011, 07:36 PM
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.
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.
06 June 2011, 07:46 PM
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.
AFAIK, There is no overload for ReadAllBytes to read only some bytes.
Using a FileStream is most likely the best solution for your intentions.
06 June 2011, 08:12 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.