Hello,
I'm having trouble with something..
I have a vector of doubles and I need to convert the vector to an unsigned char so then I can write the contents to a text file. I can do this when reading the data from a text file, just not from a vector.
void writeToImage(const vector<double>& matrix)
{
vector<unsigned char> image(matrix.size());
image.push_back(reinterpret_cast<unsigned char>(matrix[0]));
}
This was just a small example that I've been playing around with. But also have tried this:
void writeToImage(const vector<double>& matrix)
{
vector<unsigned char> image(matrix.size());
for(int i=0; (i < 512*512); i++)
{
image[i]=(unsigned char)matrix[i];
}
cout << image[0];
}
Could anyone help me please?