?
Solved

merge multiple JPEG file into one file

Posted on 2004-11-20
8
Medium Priority
?
1,301 Views
Last Modified: 2011-09-20
anyone know how to merge JPEG file into one file?

example :
i want to create software that can merge 5 JPEG file into one file.
this one file can be opened but only with my software.
so in my software i can look this images but at different page
i mean i can see 1.jpg then 2.jpg then 3.jpg

please tell me the solution...


i don't need the program but i need "How to"

thx
0
Comment
Question by:rusdyrip
5 Comments
 
LVL 6

Accepted Solution

by:
Marv-in earned 196 total points
ID: 12633622
i dont believe that the jepg format supports multipage - tiff does and you can murge multipil jegs into a tiff.
It sounds like you want to make you own img format that only your software can read. is this correct?

here is the route I would take:

create a random access datafile - this way you keep the original jpeg files intack incase you need them later.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingrandomfileaccess.asp

create a type that has the image data and possibly some extra info about the image
output all 3 types to the .xxx file

then you can use a simple vb image control to display the images.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12633704
Not sure if this will help,but check out this example:

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=43455&lngWId=1
0
 
LVL 28

Assisted Solution

by:vinnyd79
vinnyd79 earned 192 total points
ID: 12633705
Not sure if this will help,but check out this example:

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=43455&lngWId=1
0
 
LVL 7

Expert Comment

by:Enlade
ID: 12633994

Just a quick note of consideration.  To solve this problem you have one issue you have to get around.  That issue is how you are going to convert/revert a .JPG or picture into an array of BYTE.  Once you do this then it is easy enough to write/read the byte array to/from a binary file.

The problem is that there is no easy way to do this in VB other than one that I am not personally satisfied with.  As a result most sample code you see on the web for this type of problem will use this simple approuch.  Basically it goes like this.

Write the JPG to a temporary file.
Read that temporary file into a BYTE array.
Throw the BYTE array into a DB or in your case append it to you combined file.

In the code sample given by vinnyd79 this is basically what is happening; although, in its case it doesn't need the first step since it is asking the user for a path to an existing .JPG file.  That first step is only important for code that needs to manage pictures that do not already exist in files.

Now, there are harder ways to get around all of this using API calls or easy but costly ways of buying a third party image control that will give you access to the Binary image data or long runtime methods of quarying each pixel and generating the BYTE array directly from the picture control; however, if the above method does not bother you then that is probably the quickest/easiest approuch.
0
 
LVL 2

Assisted Solution

by:Tai-San
Tai-San earned 192 total points
ID: 12635005
what you could do is making a completely binary file, but you need to make it idiot secure or murphies law will haunt you.
what you need is the lengths of the files, eg:

file1.jpg = 1000bytes
file2.jpg = 1500bytes
file3.jpg = 500bytes

file lengths can be obtained with FileLen() function

then you need to open the files you want to merge 1 by 1 while having an output file ready. put in the length of the input file, and then get the data from the first file and put down the other, eg:

Open output file (For Binary)

Write size of the input file1 as a long to the output file
Open input file1 (For Binary)
Copy the contents of input file1 to output file
Close input file1

Write size of the input file2 as a long to the output file
Open input file2 (For Binary)
Copy the contents of input file2 to output file
Close input file2

Write size of the input file3 as a long to the output file
Open input file3 (For Binary)
Copy the contents of input file3 to output file
Close input file3

Close output file

now this is a very primitive way of merging.
to read you simply read the size of a long, and then read the number as many bytes as the long says. so if the long says 1000 then you read 1000 bytes and put into a normal jpg file and load it with LoadPicture()

now to extract files youll have reverse this by reading a long (4 bytes) and then copying as many bytes out of the file as the long indicates, eg:

Open input file (For Binary)

Open output file1 (For Binary)
Read the size indicator (long, 4 bytes)
copy <long> bytes out of the file and into output file1
Close output file1

etc...

Close input file

then you can use loadpicture to load the jpg as normally. when its loaded i think you can actually delete the file and have the file only in your picturebox.

I hope this answers your question
/Z out
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

840 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