Hello, I am working on my own File Format and then parse it after opening the file... But I am having a couple of issues with the speed of the procedure so I would like to ask the following:
1.- Should I open the whole file and then parse it? Or should I open it part by part and parse it that way? Which would be the best way?
2.- Which will be the best way to save the file so it won't be so big? Right now I am saving it as ASCII, I think.
3.- Which would be the best way to attach strings? I read plenderj's string attachment procedure but something is wrong with it... Should I use an array of Bytes? If so... How can I do that?
4.- Which would be the best way to draw a picture on a form? I use the API set Pixel... Some would say BitBtl but since the File Format is of my own, how could I use it?
Thanks for your attention... Don't answer all questions if you can't, if you are able to help me with just one of them I will be very happy.
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Thanks for answering, David. What I am doing is to create my own format for saving pictures but they are a little bigger than gifs and it takes longer to load a text file and parse it than doing it from a bitmap and I think it's because of the time it takes to manipulate strings.
The file can turn into MBs if the picture is big and that's why I am asking...
(Added: )
When saving a picture I need to attach a new part to the string that is holding the whole file. I do it this way:
VB Code:
strFile = strFile & strLine
Last edited by Tec-Nico; Aug 20th, 2005 at 10:46 PM.
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
I don't see why you are creating your own picture format. There are plenty of good ones out there. JPG are compressed, but lose if you zoom in close enough.
RAW is the newest format out there. I saw it demo'd the other night.
It is loseless, and a little bigger than jpg. Newer digital cameras use it.
I am creating the format for my own program.. so the painting will be faster and the picture would store some features that would be easier to read from the program than saving them into a different file. Am I making sense?
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Yep. I would use a UDT header at the start of the file to describe the picture following it, and then read it in two parts, UDT first, and using the descriptive info in the UDT, read the picture itself. You can use Get in binary mode to read bits of files.
Uh, I just read your bit of post about strings. Don't use them. Use byte arrays, much much quicker. You have control over exactly where everything is at all times; something that's hard to achieve with strings unless you know exactly what you're doing, and it is much more complex.
How you would display a picture contained in a byte array, I don't know. That is a different matter. Are you creating your own picture format or saving a StdPicture sort of object?
I see it.. but I meant for when I would have to read every pixel from a picturebox in order to save the file.. Instead of using the string I am putting all into I would like to see how to do something like:
a = a & "b"
Should I use the redim everytime I am going to add a new byte? How can I handle it when I am going to save it?
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
You are reading each pixel individually?? Oh goodness, that is going to be slow... Just Put the contents of the picture into the file, and then when you want to read it, read it into a StdPicture object.
VB Code:
' Save it
Dim udtHeader As FileHeaderThing
' fill the UDT with details
udtHeader.lpPictureData = LenB(udtHeader) + 1
Open [filename] For Binary Lock Write As #lFF
Put #lFF, , udtHeader
Put #lFF, (udtHeader.lpPictureData), picPicture.Picture
yes, because i am translating the picture into my format.. i am going to continue this tomorrow.. i am very tired now. thanks for your answers and i hope i can ask you more if i have some other doubts.
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Hmmm... Penagate, I have another doubt.
The problem is that the size of every line of the picture has a different length.
Example:
Let's say there are 30 red pixels... So my data would look like:
255x30
How would I be able to read that when using Bytes? And how would I be able to store it? Right now I am still playing with the code but I would love to have more pointers so I wouldn't have to spend a lot of time analyzing and trying to understand what I am doing..
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
" I never did anything worth doing entirely by accident.... Almost none of my inventions were derived in that manner. They were achieved by having trained myself to be analytical and to endure and tolerate hard work."
" Many of life's failures are experienced by people who did not realize how close they were to success when they gave up. "
- Thomas Alva Edison-
Those all are 8-bit images made in real time, but it shouldn't be impossible to change it to 32-bits. It actually might be easier to handle it in 32-bits as you don't need to worry about "dividable by four bytes per row" thingy. The codes introduce the use of DIBs, Device Independent Bitmaps.
If interested, I also have a Transport Tycoon Deluxe GRF file reader, which reads several sprites from a TTD graphics file and displays the selected one. 8-bit as well, so no many changes in the techinal side...
When I thought about handling byte arrays instead of strings your name came to my mind, Merri. That was also because of the speed issue.
I appreciate every comment made to me regarding this project that is about to be started. After making some tests with get and set pixel API, I developed my own format but translating it was pretty slow and so was reading it from the file even when drawing the picture was faster.
What's special about this format? It might have been already discovered by Merri: The pictures are built out of what could be a description, so the colors might change depending on this. The idea is to have general pictures and then customize them based on small text descriptions.
The problem here is that the files need to be the smallest possible and able to support animations.. They are going to be send through the internet and the transfer should be fast enough so people wouldn't notice when it happens.
I am going to take a look at the MetaBalls project and I am interested in the Transport Tycoon Delux GRF file reader and in everyone's suggestions. Thank you to all
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Here is the GRF reader. Originally meant to be a convertor, but I never got as far as coding the editing and saving. TTD community is still alive very well and the game hasn't died. Going strong for a ten years old game
Anyways, you ought to find good tips for handling a file in the project.
A ten year-old game? is it going to be finished soon?
Seems very unlikely, they talk actively about TTD development on IRC, there are several projects going on which include creation of new vehicles, new tools for building them, TTDPatch which edits the original game, OpenTTD which is a custom coded C version of the game... just a lot of stuff