Qbasicnews.com

Full Version: Sprite saving styles...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When I look at sprite files in notpad saved through BSAVE. I see a bunch of wird characters, but they reduce the file size. What are they doing?
well, sprites/images aren't stored as text and use the full range of 8bit characters. Some of them look weird or not at all in windoze notepad.
Sprites are completely meaningless when read in text form. You don't need to worry about whatever wierd ascii characters BSAVE spits out - there's no easy way to edit them without using qbasic.
bsave doesnt compress, and except for a 7-byte header, it doesnt waste space. you see, you can only plot 256 different colors anyway. and there happens to be 256 different characters in a string. So BSAVE says "hmm... why not just store the image in one massive string of characters, with each characters ASCII value being the color of the pixel it represents". And God said "Let there be a BSAVE dump", and He was pleased.

When you compress something, you're actually representing repeated patterns as one character. the decompressor reads the patterns, and turns it back into an image. think of it like this. this is a long post. but let's say you turn every instance of "and" with "xx", every instance of "you" with "xy", and every instance of "bsave" with "xz". the post gets a little bit smaller. This is how real image compression works.
Sorry, I've been doing so much, my responses have been a bit slow...

So, is there any method to saving the sprite in the way that most sprite editors save them? Or do I have to save them number by number?
Most QB sprite editors just use BSAVE to make a binary copy of your array in a file.

Code:
DEF SEG=Array%(0)
BSAVE "filename", VARPTR(Array%(0)), size%

Being size% the size of your array in bytes. With integer arrays from 0 to UBOUND, it is 2*(UBOUND+1).
Well, i think there is a missunderstanding of the concept data here. Data is just values, it makes sence only if interpreted in the right way. What you see is just a bunch of values. It just so happens that notepad or whatever displays those values as ascii characters since it is a texteditor. A byte could simply be a one byte integer, or a ascii charachter or simply something else. It's all a matter of how you interpret it. There is no memory or file type for integer or string. Anyway, the bsave format is a header followed by the pixels as they are in memory. Each one byte represents a pixel in 8 bit. There's no more to it then that.