Extracting image from a binary file...!!!!

This is a discussion on Extracting image from a binary file...!!!! within the C++ Programming forums, part of the General Programming Boards category; Hello friends., I need your help..!!! Actually, my task this -> when i execute the program, it should extract an ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Location
    Chennai, Tamil nadu, India
    Posts
    30

    Extracting image from a binary file...!!!!

    Hello friends., I need your help..!!!

    Actually, my task this -> when i execute the program, it should extract an image file in jpeg(jpg) format. That image file i will specify while writing the code..

    Now my question is, Is This Possible..?? Is there anyway to extract an image file.. Sorry i'm new to files concept in c++. It may in any language, C or in C++.

    Or if i supply a binary file as input to read and extract it as an image file,
    Then,
    how can i convert the image file(to be extracted) into a binary file that is to given as input..??
    Even if it's converted as a binary file, then, how else can i read it..?? and how can i write as jpg file..??

    Programming experts, just don't get annoyed and please explain me..
    Share your ideas please...!!!

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,623
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    16
    What exactly do you mean with "extract an image"?
    Is it "hidden" somewhere inside a bigger file? If yes, then you should scan the file for a JPG header and if you find it, try to read a JPG from there.
    You can use a library such as DevIL to actually load the JPG.

    ________________________________
    Visit my project: Derivative Calculator
    Last edited by TomasRiker; 05-18-2012 at 04:15 AM.

  4. #4
    Registered User
    Join Date
    Jan 2012
    Location
    Chennai, Tamil nadu, India
    Posts
    30
    @TomasRiker....,
    Well, can you please specify where can i find such header file...? And where can i learn to hide an image in a file and how to use it..???

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    All binary files hold the same information - pure binary data. However it is the interpretation and usage of the data that differentiates the types of binary files. Therefore what you said makes no sense at all. An image file is a file that contains binary data that when processed correctly creates an image. Executable files contain binary data that when processed correctly execute code. So in short if no image exists in a binary file then no image can be extracted from it. If you wish to hide an image in a file (which is pointless) you would read the file in, pick an offset from start at which to embed the data, embed the data here, and then copy the remainder of the original binary file from offset + <binary_chunk> to the end of the file. However this is going to do nothing but create a file that cannot be read by any program except yours since no other program is going to be able to read a customized version of the file format they are designed to read and process.

    Most 'chunky' file formats usually embed header information prior to each chunk. Each chunk is then read in based on the header information. In my own file formats I use this to embed several models, textures, sounds, etc. all in the same file. However my code understands the format and can read it in correctly. Other programs cannot read the data since it follows a customized format.


    What are you trying to do and why?
    Last edited by VirtualAce; 05-27-2012 at 10:13 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merge multiple image file into one image
    By mr_empty in forum C++ Programming
    Replies: 7
    Last Post: 12-09-2009, 01:12 PM
  2. How to write image data to binary PGM file format(P5)?
    By tommy_chai in forum C Programming
    Replies: 6
    Last Post: 11-03-2007, 10:52 PM
  3. how to convert a bitmap image to a jpg image file using C++?
    By nomer in forum Windows Programming
    Replies: 4
    Last Post: 06-04-2006, 07:40 PM
  4. read binary image w/ fstream?
    By new90 in forum C++ Programming
    Replies: 2
    Last Post: 12-11-2005, 06:59 PM
  5. Image class - loading image file
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 07-11-2004, 01:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21