nickworonekin / puyotools

Puyo Tools is a collection of tools and libraries used to access the contents of various game files. Although it was initially built to handle files used in Puyo Puyo games, it can handle files used in other games as well.
MIT License
99 stars 24 forks source link

VrTextureEncoder.Save does not reset stream position #6

Closed michael-fadely closed 7 years ago

michael-fadely commented 9 years ago

VrTextureEncoder.Save doesn't reset the destination stream's position to 0, and this will cause .Is() to fail since Length - Position is 0.

nickworonekin commented 9 years ago

Hmm, should it reset the position to 0? I designed it that way so you can easily write to the stream multiple times in a row without having to use a separate stream and writing that data to the stream. Image.Save seems to work this way as well (aside from the fact that you need to start writing at the beginning of the stream), though I haven't tested this.

ToStream on the other hand should reset the position to 0. That's something I need to change.

michael-fadely commented 9 years ago

That's a fair point; maybe not then. It certainly wasn't a straight forward fix for this program of mine, though. It took a while of debugging to figure out what the problem was (although admittedly it shouldn't have, so that's on me).

nickworonekin commented 7 years ago

I'm leaving the Save method as that is (Image.Save works this way too). I changed the stream returned by ToStream to have it's position set to the beginning of the stream.