• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extracting images from binary file

 
Jeff Nelson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42970
73
  • Mark post as helpful
  • send pies
  • 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).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!