Hello helpmeimnotthesmartest,
Alas I am not that familiar working with image files that your program uses.
The main point of my last post is that
1 2
|
fstream myfile;
myfile.open ("example.txt");
|
This only opens the file, but does not say if it is for input or output.
I see that you edited your OP and now the above bit of code now says
ofstream
. I do not recall if it was that way to begin with or not, but if you changed that code, do not do that. It only confuses people that read what you have posted and can not find anything wrong with the code.
It is also a good idea to put "Edit:" at the end and say what you changed, so that everyone will know.
Something I noticed in the OP the first switch the default case comes first. I do not know if it makes any difference, but I have always seen the default case as being last. Also the "return" statement will never allow the case to reach the "break" as it will leave the switch before that.
In the second post the for loop can be written as:
for(int i = 0; i <= width * height;)
. Since you are changing the value of "i" inside the for loop you do not need the third part, but you do need the second ";" for it to work properly.
The for loop looks like it will process the image data, but what do you do after this for loop to read what is left. Do not look to this for loop to read the entire file.
You say that you need to open an output file for the program to work, but you also say that yo do not need an output file. This says to me that something is wrong and most likely in code that you have not shown.
I have found that problems and errors do not always start where you think they do. Errors can start several lines above where the compiler says it is and problems can start in functions that may come before you you see a problem or from functions that are called from where the is being seen.
Even though I do not understand what the program is doing. Having code that will compile and run along with the file that you are testing I can usually figure out what is going wrong.
Someone who is use to working with image file may see something I do not or have an idea that I do not know about.
Sorry I could not be of more help,
Andy