Solved

read image binary data for output

Posted on 2003-11-04
7
514 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
Comment Utility
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
Comment Utility
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
Comment Utility
Where is your binary data coming from?  A source file that contains multiple JPG files crammed into one file?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:NBrownoh
Comment Utility
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
Comment Utility
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
Comment Utility
thats exactly what im thinking.
0
 

Author Comment

by:brench
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

10 Experts available now in Live!

Get 1:1 Help Now