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

Problem reading and writing a black and white image #1

Open
feraudyh opened this issue Mar 31, 2022 · 0 comments
Open

Problem reading and writing a black and white image #1

feraudyh opened this issue Mar 31, 2022 · 0 comments

Comments

@feraudyh
Copy link

I have three grey level images. I think all are uncompressed.
In finger_MA.bmp and 0001.bmp the header value of colors_in_palette is 256 (as it seems it should be). This causes an error, with a message that the method does not supply compressed images. But it seems to me that the colors_in_palette should not have anything to do with compression as your code seems to imply.
One file (finger1_1.bmp) has header.colors_in_palette equal to 0 after reading which is a bit strange.
Here is my test code:

`
#include
#include
#include "BMPMini.hpp"

using namespace image;

void test_BMPMini(const std::string &inPath, const std::string &outPath)
{
BMPMini bmp;
try {
bmp.read(inPath);
}
catch (std::ios::failure& failure)
{
std::cout << failure.what() << "\n";
return;
}
catch(std::invalid_argument &arg_err)
{
std::cout << arg_err.what() << "\n";
return;
}
catch (...)
{
std::cout << "could not read from " << inPath << "\n";
return;
}
try{
auto img_view = bmp.get();
bmp.write(img_view, outPath);
}
catch (...)
{
std::cout << "could not write to " << outPath << "\n";
}
}

int main()
{
const std::string inPath1 = "finger1_1.bmp";
const std::string outPath1 = "finger1_1_copy.bmp";
const std::string inPath2 = "finger_MA.bmp";
const std::string outPath2 = "finger_MA_copy.bmp";
const std::string inPath3 = "0001.bmp";
const std::string outPath3 = "0001.bmp";
test_BMPMini(inPath1, outPath1);
}
`
ConsoleApplicationGreyLevelBMP.zip

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