• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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).
 
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic