Link to home
Start Free TrialLog in
Avatar of brench
brench

asked on

read image binary data for output

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
SOLUTION
Avatar of NBrownoh
NBrownoh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brench
brench

ASKER

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
Where is your binary data coming from?  A source file that contains multiple JPG files crammed into one file?
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 :)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thats exactly what im thinking.
Avatar of brench

ASKER

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