• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extracting images from binary file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have access to a binary file that contains 1 or more images. I am
trying to access the images in java so that I can extract them and
place them in a directory. I know the file is in little-endian format
and I used com.mindprod.ledatastream.LEDataInputStream to read it. I
the first line is ascii and tells me the length of the blob. My issue is I do not know how to navigate throught the file to extract each image. I know i have issues that will have me use sime Image api later on, but if I can not isolate the images into logical chunks I will not get anywhere.

Any suggestions, code snippets?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jeff-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it - please adjust it accordingly, which you can do right here. In particular, a last name is required as well as a first name. Thanks for your prompt attention to this matter.

Enyoy your time here.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As to your question, what file format is this? It's hard to make sense of a blob if one doesn't know which of the myriads of image formats it's in.
 
Jeff Nelson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The file(s) in the binary create a jpg. The binary file was create in C and the author states that all he has to do is output the contents of each image as a file name with a .jpg extension.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a strange way of bundling images. Sounds like you need to figure out yourself where one image ends and the next one starts, extract the bytes for each one, and then save them separately.

The JPEG file format has length fields embedded which you can use for this purpose, but it's going to require some programming (not really bad, though).
reply
    Bookmark Topic Watch Topic
  • New Topic