Thread: STL, Queue And Images (Need Help)

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    68

    Exclamation STL, Queue And Images (Need Help)

    I am tring to write a program that can create a queue of raw Images. I have got some success doing it all i want to know is that how can i take the first image from the queue and write it back out....... Please help me....Also i am show what part i am faling to do i have comment that by saying "//I get an error"

    Here is the code....... and i am also attaching the raw Image file
    Code:
    #include<iostream.h>
    #include<fstream.h>
    #include<string>
    
    #include<queue>
    
    class ImageQueue
    {
    public:
    
    	ImageQueue(){
    	 width = 0;// image width
    	 height = 0;// image height
    	 size = 0;//image size 
    	 bitCount = 0;// image is 8 bit, 16 bit, 24 bit,32 bit
    	}
    
    
    	~ImageQueue(){
    	 width = 0;
    	 height = 0;
    	 size = 0;
    	 bitCount = 0;
    	}
    
    
    	void setWidth(int value){
    		width = value;
    	}
    
    	void setHeight(int value){
    		height = value;
    	}
    
    	void setSize(int value){
    		size = value;
    	}
    
    	void setBitcount(int value){
    		bitCount = value;
    	}
    	
    
    	int getWidth(void){
    		return width;
    	}
    
    
    	int getHeight(void){
    		return width;
    	}
    
    
    	int getSize(void){
    		return width;
    	}
    
    
    	int getBitcount(void){
    		return width;
    	}
    	unsigned char Frame[1024*700];
    private:
    	int width;
    	int height;
    	int size;
    	int bitCount;
    	
    };
    
    int main(void)
    {
    	std::queue<ImageQueue *> values;//image Queue
    	std::string filename = "frame1.raw";// File Name
    	ifstream Inputfile;//InputFile Stream
    	ofstream output;// OutPutFile Stream
    
    	ImageQueue *iQueue = new ImageQueue();	// object to Class ImageQueue
    
    	int i = 0;//counter
    	
    	Inputfile.open(filename.c_str(),ios::binary);
    	output.open("test.raw",ios::binary);
    
    	if(!Inputfile.is_open())
    	{
    		cout<<"Cant Open The File"<<endl;		
    	}
    	else
    	{
    		char c = '\0';
    		while(!Inputfile.eof())
    		{	
    			c = Inputfile.get();
    				(*iQueue).Frame[i] = c;
    			i++;
    		}		
    	}
    	
    	values.push(iQueue);
    	cout<<values.size();
                    
                    // I get an error
                    output<<values.pop();
    	return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > output<<values.pop();
    You're trying to output the queue entry (a raw pointer), not what the queue entry contains (your data)

    Perhaps you mean to overload << to do the right thing when trying to output your class

    Also, your array has 716800 elements, and your file is barely a 10th of this size

    Nor do you call your setWidth() functions

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    68
    The reason why i am not using any of the other function like SetWidth(), setHeight(), is because at these poing i want to know how to each sigal element of the queue. So if you know how to then let me know and also let me know simply way of overloading <<......Thanks

    Pratik

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. STL, Queues And Images
    By simly01 in forum C++ Programming
    Replies: 3
    Last Post: 06-24-2002, 12:31 PM