Solved

read image binary data for output

Posted on 2003-11-04
7
524 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

739 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