Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused with usage with my input image #13

Open
RamyRamo opened this issue Aug 11, 2023 · 0 comments
Open

Confused with usage with my input image #13

RamyRamo opened this issue Aug 11, 2023 · 0 comments

Comments

@RamyRamo
Copy link

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant