Problem reading file in BMP convertion

Discussion in 'C' started by luiceur, Aug 1, 2008.

  1. luiceur

    luiceur New Member

    Joined:
    Aug 1, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am trying to convert a bmp file to ppm file.In order to do that:
    1-I am reading the bitmap file
    2-Order the new aux file
    In step 2 is where i got the problem,i can't read the same!! Please,could anyone tell me what the hell i am doing wrong???

    Code:
    #include<iostream>
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #include <fstream>
    #define MAXW 1024
    #define MAXH 1024
    
    
    using namespace std;
    
    void loadBMP(char* infile,char* outfile);
    void putOrder(char* infile);
    int numberOflines(char* infile);
    
    
    int main (int argc, char* argv[] ) {
    
    
            int BMPw;
            int BMPh;
    
            loadBMP(argv[1], argv[2]);
    	putOrder(argv[2]);
    	return 0;
    }
    
    void loadBMP(char* infile,char* outfile) {
        
        ifstream in ;
        ofstream out;
        int width;
        int height;
    
        //Open File
        in.open(infile);
        out.open(outfile);
        
        in.seekg(54,ios::beg);
        
        while(!in.eof()){
    
    	out << in.get() << endl;
        }
        in.close();
        out.close();
    }    
    void putOrder(char* infile){
        
        ifstream inf;
        ofstream outf;
        int nLines;
        string t;
    
        inf.open(infile);
        outf.open("outOrder");
    
        inf.seekg(10,ios::beg);
        while (!inf.eof()){
          outf << inf.get() << endl;
        } 
        inf.close();
        outf.close();
    }
     
    Last edited by a moderator: Aug 1, 2008

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice