Advertisement

Custom file format...

Started by April 01, 2002 02:04 PM
5 comments, last by shakazed 22 years, 7 months ago
How do you make your own file format, and most important how do you get data from it? sHaKaZeD
Err, you work out what information you need to store, then you work out how you're going to organise it.
And you load it the same way you load anything else - except you parse the information differently.

What's the problem?

EDIT:
Do you need to know how to load text data, binary data? Do you need to know general information about how to parse the data that you're loading?

John B

[edited by - JohnBSmall on April 1, 2002 3:28:27 PM]
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
Advertisement
i think he/she/whatever means like.. take a .bmp file and rename it but still load it as bmp
or something like thta.. maybe pack em with own file sorts..
True hackers are intelligent, they have to be. Either they do really great in school because they have nothing better to do, or they don't do so well because school is terribly boring. And the ones who are bored aren't that way because they don't give a shit about learning anything. A true hacker wants to know everything. They're bored because schools teach the same dull things over and over and over, nothing new, nothing challenging.
quote: Original post by shakazed
How do you make your own file format, and most important how do you get data from it?

<font face="impact">sHaKaZeD</font>


It depends on what your doing. Most people make some called a header (normally writtten first. Although it can be anywere in the file) that stores the information need to load the data contained in the file. For example, most images store information on the images size, resolution, palette, and compression if it''s used.

''Here an example. I wrote it in VB cause i am lazy.
''a very simple picture format

Private Type header
width as integer
height as integer
end type
dim header as header

header.width = 100
header.height = 100

open "myimage.pic" for binary as #1
put #1, , header

for y = 1 to header.height
for x = 1 to header.width
imgdata = point(x,y)
put #1, , imgdata
next x,y
close

to read it you would do the same process in reverse
you get the header (get #1, , header) then the image data.


I hope this helps. If you want examples try www.wotsit.org


Well, if you want to know about making your own archive/pack file format (for storing a load of files in one big file), there are articles at:
flipcode
(the "Programming a Virtual File System" series, and "Faster File Access With File Mapping")

Or there''s one (and possibly more) here on GameDev.net

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
I’ve been using XML more and more
Advertisement
Uhm....right....well...hmm...I´m quite sure I got it.

sHaKaZeD

This topic is closed to new replies.

Advertisement