🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Making own files?

Started by
4 comments, last by FlorianapoliS 22 years, 10 months ago
Hi, I saw in one of the other forums that you can make your own type of graphic files, I was just wondering how this done?
Advertisement
simple
you define a header that has some info about the file like
color depth width and height
then you just store the colordata

type Header
width as long
height as long
bpp as byte
end type

type color_data
r as integer
g as integer
b as integer
end type

then you just save one heard and width*height color data blocks and there you have it



-VBLimits
Sorry about the Spelling..
-VBLimitsSorry about the Spelling..
Thanks, but I''m really new to this, and I don''t quit understand? By Header do you mean a *.h file? or header of the graphic file that I''m trying to make? Btw I''m programming in C++.

The best advise that I could give you is to look at a few examples of graphic file formats. You can start by going to the Win32 documentation by microsoft and search for BITMAP. The BMP and PCX file formats are fairly simple to learn. From there, you could come up with your own.

Alek
as file is a file is a file is a file...
BAsically a file contains bytes, and it''s up to you to figure out what they mean. A JPEG is not a JPEG because you stick .JPG to the end of the filename... it''s a JPEG because if you read the bytes contained in the file, they are *organised* in way that is specific to JPEG.
What VBLimits means by "header" is this.
Generally, a file format is composed of the header part and the data part.
The header part are the first bytes contained in a file, they are used to say "hello, I am a JPEG file, so this is how we are gonna work". It gives you some info in a way that is specific to the file format you are using.
Typically, the first few bytes are a signature... check a GIF file for instance, with Notepad. You''ll see the first bytes are ... "GIF89a" hehe
Then, since you know what file format you are looking at, you know where to find the stuff you want.
Things like "is this a 256 colours file ?", things like "where is the palette?" (e.g. in a PCX file, you''ll find the palette data at EndOfFile - 768, i.e. the last 768 bytes of the file.), or "what are the dimensions of the file?"
Generally the header is of a fixed size, say 256 first bytes of the file. Then you get the data. Because you have grabbed the width and height of the picture in the header, you will read data until you have enough pixels... (Ok, at least that''s for the PCX file format, it can varies).

So now, all you need is to find the structure of the file format you want to read, and read the files you wanna read
check out Wotsit.org. you''ll find tons and tons of file formats described there !

If you don''t understand, ask again. Though I think this should be in another forum.
(See guys, that''s why I wanted us to have another moderator... digisoap NEVER moves those lost threads away... )


Sancte Isidore ora pro nobis !
-----------------------------Sancte Isidore ora pro nobis !
Thanks tons!! :D

This topic is closed to new replies.

Advertisement