Solved

read image binary data for output

Posted on 2003-11-04
7
519 Views
Last Modified: 2010-05-01
I'm reading image binary data into a byte array, then parsing out the individual images to output them as .jpg files. However, the output files are only viewable in Photoshop.

Is there a way to create JFIF files or some other format that would be immediately viewable (in apps other than Photoshop)? If not, is there any way to convert my .jpg output files to viewable files?

Thanks.


Brad
0
Comment
Question by:brench
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Assisted Solution

by:NBrownoh
NBrownoh earned 125 total points
ID: 9683476
are you putting more than one image into a file?  or more than one image into an array? If its the first then i would seperate each image into its own file.  If not then i def wouldnt load more than one image into an array.  I would think that those would be your main problems.  Photoshop probably repairs the image to view it since it is a very well written program.
0
 

Author Comment

by:brench
ID: 9686650
NBrownoh,

I put each image into its own .jpg file. When I initially read the binary data from disk, I store it all in the byte array (the file I'm reading in is large--e.g. 150MB). So I have every binary "character" read into the array and then I go through the array, checking for certain characters to tell me where the start and end of each image are. I'm unclear as to why it would cause a problem to load more than one image (or the data for more than one image) into the array.

I noticed that the .jpg file is not in JFIF format. I think that .jpg files will only open in other apps (e.g. Internet Explorer) if they're in this JFIF format. Do you know? I'm really just reading the binary data straight into an output file (from the array) and giving it a .jpg extension. Photoshop, for some reason, is able to translate/interpret the data, but other apps aren't. Do you know how I can generate output that is in the JFIF format, or do you know how I can convert my .jpg output files to JFIF format?

Thanks.


Brad
0
 
LVL 1

Expert Comment

by:Mutare99
ID: 9687210
Where is your binary data coming from?  A source file that contains multiple JPG files crammed into one file?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 3

Expert Comment

by:NBrownoh
ID: 9688273
Mutare99,

i pretty positive he is just loading multiple images into one byte array.

I dunno, as far as that though.  It just seems like youd be setting yourself up to get knocked down, you could use a multi dimensional array like pic(1, x) x being the current picture number you are loading. or something of that nature.  That might not be your problem in full, but it should at least clean your code up a few lines and help optimize it a little.  As far as jpeg encoding goes i played with it a few years ago and never really got the hang of it since i wasnt as good back then as i am now.  didnt understand classes and how to use them :)
0
 
LVL 1

Accepted Solution

by:
Mutare99 earned 125 total points
ID: 9688705
Well, I guess I'm wondering if the original JPG files will open in apps other than photoshop, or if they are messed up to begin with?  If they work to begin with, then I'd say the cramming them all into one byte array might be messing something up.  But, if they're bad to begin with, converting them to a more recognized JPG format is the real issue.  If so, here is a great site for file formats that may be able to help you convert them to a working form:

http://www.wotsit.org/search.asp?page=5&s=graphics
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9688739
thats exactly what im thinking.
0
 

Author Comment

by:brench
ID: 9694542
I was able to solve the problem I was having.

I'm reading binary data from a file given to us on CD. Yes, there are multiple images within the file. Text containing data precedes each image so I have to extract the data (which contains info related to the image) and then extract the image. I should make clear that I'm not starting with .jpg files. It's just a bunch of binary data that I output to a file (and then load to a database).

Once the data is output, the resulting file would not open in anything but Photoshop. What we realized is that the first few lines of data output were not necessary and were in fact causing the file to not open (except in PS). We simply started our output at a different point and the resulting .jpg file opens fine (e.g. in IE, Paint, Windows Picture and Fax Viewer).

Basically, if you look at a .jpg file in Notepad, you'll notice that it starts with something like "ÿØÿà JFIF". Once I output the binary data so that the file started at this same point, the images were viewable. Don't know if I'm being clear on this. If you want more details, let me know.

Thanks for your input.


Brad
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

813 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

12 Experts available now in Live!

Get 1:1 Help Now