toojpeg
toojpeg copied to clipboard
Confused with usage with my input image
Hello, Please I need to use your repo and use lena.PNG as input image, so I read the image in this way, but this not correct how can read the image in correct way?
ifstream im;
im.open("lena.PNG",std::ios_base::binary);
if (im.is_open())
{
cout<< "function success\n";
}
else
{
cout<< "unable to open file";
}
//get length of file:
im.seekg(0, im.end);
int n = im.tellg();
im.seekg (0, im.beg);
//allocate memory:
///char* image = new char[n];
const auto width = 512;
const auto height = 512;
// RGB: one byte each for red, green, blue
const auto bytesPerPixel = 3;
// allocate memory
auto image = new char[width * height * bytesPerPixel];
//read data as a block:
im.read( (image), n);