Jun 22, 2010 at 9:44pm UTC
Please advise me how to read the JPEG file into byte array. I was trying to use ifstream and ios::binary as following:
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream myFile;
myFile.open("butterfly.jpeg", ios::in | ios::binary);
//not the end of file
while(!myFile.eof())
{
int line;
myFile >> line;
cout << line << endl;
}
}
Though, what I got was infinitive print of "4" like this:
4
4
4
4
...
Thank you.
Jun 22, 2010 at 9:57pm UTC
What are you expecting outputting JPEG data to the console to achieve?
Jun 23, 2010 at 1:33am UTC
Thanks,
I will try this right now. What I have to do is to write a JPEG decoder (taking in a JPEG file and produce a BMP file).
So right now, I try to get the file into stream of bytes and apply reverse compression algorithms.
Thank you. If you have any more advise for me, please let me know.
Jun 23, 2010 at 1:56am UTC
Dear Galik,
I get compiling error with your code for line 7 as it says:
Multiple markers at this line
- unused variable 'in'
- unused variable 'binary'
- `ios' has not been declared
- `in' was not declared in this
scope
- `binary' was not declared in
this scope
I am using Eclipse IDE with MinGW compiler.
Thank you.