I was playing around the proposed 2d graphics library for C++, the old implementation that I got from here https://github.com/cristianadam/io2d, I am trying to render an image surface on a display surface which i load into vector of unsigned char using the std::copy algorithms
auto loadimg(std::ifstream &file) {
std::vector<unsigned char> img_data{};
std::copy(std::istream_iterator<unsigned char>(file) ,
std::istream_iterator<unsigned char>(), img_data.begin());
return img_data;
}
I tried std::move too.
And the client for the loadimg function goes like this
std::ifstream file("packagelevel.png");
img_surf.data(loadimg(file));
although the program compiles using visual studio 2017. But I am getting the error at debug "Can't derefence value initialize iterator" and the exception was thrown at the loadimg return statement.What am I doing wrong?