Solved

Append multiple picture files...

Posted on 1998-10-14
5
136 Views
Last Modified: 2010-04-30
Having problems appending files!
How do I Read in two small picture files into seperate buffers, without reading past end of files, and then write them out appended in another file? VB4.0
0
Comment
Question by:jersam
  • 3
5 Comments
 
LVL 14

Expert Comment

by:waty
Comment Utility
Picture files are not traditionnal files, what do you want exactly do?

You can't store 2 pictures in one picture (the first followed by the second ).

If you want to overlap them, it is possible.
0
 

Author Comment

by:jersam
Comment Utility
OK... I have this Program called visual places...
I have pretty much figured out the file format for the gesture files.
The format is as follows:
     A header of 50 bytes or so
     A 20 by 20 Gif file (Icon for the Program)
     A Gif file with multiple pictures( Animation)
     A Wave File... Self explanitory

My Problem is I am trying to write a program to Append a gif file that could be of variable length after the 20 by 20 Gif
file. I can then enter the header at the top with my hex editor and have a File that hopefully will work in my Program.

I Have Been able to read the file in its entirety except for the null bytes..
For Example...

File 1 (GIF file)first 32 bytes:

                   Hex                              Asci      
47 49 46 38 39 61 14 00 14 00 b3 00 00 00 00 00  GIF89a..........
63 00 00 9c 00 31 ce 00 31 ff 00 00 ff ff ff ff  c....l..l.......
 
File 2 (Output File) in hex form:

                   Hex                               Asci  
47 49 46 38 39 61 14 14 b3 63 9c 31 ce 31 ce 31  GIF89a...c.l.l..
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................

See my problem ?
When I read it in I get The file without the null Bytes
I am not reading the file in properly...
I have tested to find this out.

So I guess the question is really how to I read it in properly...
I can Append the files fine... If I can Read them in right...

If U understand I would can understand my babling...
Please help! More Points may be available
0
 
LVL 2

Accepted Solution

by:
AllenC_Jr earned 50 total points
Comment Utility
'. |You could Load the File Binarily, Like this.

Private Type BinFile
FileBytes() as Byte
End Type
Private Sub OpenFile(Filename as String) as BinFile
Dim FF as Long, FileBytes as BinFile
FF = FreeFile
Redim FileBytes.FileBytes(1 to FileLen(FileName))
Open Filename for Binary Lock Read As #FF
Get #1, 1, FileBytes.FileBytes()
Close #FF
OpenFile = FileBytes
End Sub

Private Sub Form_Load()
Dim MFil as BinFile
MFil = OpenFile("C:\New.txt")
Msgbox CHR(MFil.FileBytes(1)) 'In order to read each byte properly you need to change it to Ascii format, it is currently in A byte format(ASC).
End Sub

'. |Hope this Helps
0
 
LVL 2

Expert Comment

by:AllenC_Jr
Comment Utility
'. |You could Load the File Binarily, Like this.

Private Type BinFile
FileBytes() as Byte
End Type
Private Sub OpenFile(Filename as String) as BinFile
Dim FF as Long, FileBytes as BinFile
FF = FreeFile
Redim FileBytes.FileBytes(1 to FileLen(FileName))
Open Filename for Binary Lock Read As #FF
Get #1, 1, FileBytes.FileBytes()
Close #FF
OpenFile = FileBytes
End Sub

Private Sub Form_Load()
Dim MFil as BinFile
MFil = OpenFile("C:\New.txt")
Msgbox CHR(MFil.FileBytes(1)) 'In order to read each byte properly you need to change it to Ascii format, it is currently in A byte format(ASC).
End Sub

'. |Hope this Helps
0
 
LVL 2

Expert Comment

by:AllenC_Jr
Comment Utility
OOps sorry about that i meant to say


Oops change the

Get #1, 1, FileBytes.FileBytes()

To

Get #FF, 1, FileBytes.FileBytes()

I noticed that AFTER i submitted it

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now