Skip to content

Problem reading and writing a black and white image #1

@feraudyh

Description

@feraudyh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions