Skip to content

Conversion of any RGB pixel to signed CMYK conversion is broken #479

Closed
@mloskot

Description

RGB pixels based on unsigned integral channels are not correctly translated to CMYK space with full range of signed integral channels.

The original implementation did not handle properly signed CMYK pixels, so this issue is independent from #406.

C++ Minimal Working Example

#include <boost/gil.hpp>
namespace gil = boost::gil;
int main()
{
    // black
    {
        gil::rgb8_pixel_t src{0, 0, 0};
        gil::cmyk8s_pixel_t dst;
        gil::color_convert(src, dst); // dst={0, 0, 0, 0}
                             // expected dst={-128, -128, -128, 127}
    }
    // white
    {
        gil::rgb8_pixel_t src{255, 255, 255};
        gil::cmyk8s_pixel_t dst;
        gil::color_convert(src, dst); // dst={0, 0, 0, -128}
                             // expected dst={-128, -128, -128, -128}
    }
    // blue
    {
        gil::rgb8_pixel_t src{0, 0, 255};
        gil::cmyk8s_pixel_t dst;
        gil::color_convert(src, dst); // dst={127, 127, 0, -128}
                             // expected dst={127, 127, -128, -128}
        print(1, src, dst);
    }
    // yellow
    {
        gil::rgb8_pixel_t src{255, 255, 0};
        gil::cmyk8s_pixel_t dst;
        gil::color_convert(src, dst); // dst={0, 0, 127, -128}
                             // expected dst={-128, -128, 127, -128}
    }
}

References

Environment

  • Version (Git ref or <boost/version.hpp>): <=1.72, current develop

Metadata

Assignees

No one assigned

    Labels

    cat/bugBut reports and bug fixesgood-first-issueOpportunity for new contributors to help improving GIL

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions