Skip to content

Division by zero  #5

@crazylyle

Description

@crazylyle

In ColorHelper/ColorHelper/Converter/ColorConverter.cs,
at lines 23 to 25:
c = (1 - modifiedR - k) / (1 - k);
m = (1 - modifiedG - k) / (1 - k);
y = (1 - modifiedB - k) / (1 - k);
we have a division by zero if k == 1. k is computed at line 22 as one minus the max of r,g,b.
So if all of r, g, b are 0, the max is zero, then k is 1, and 1-k is zero. Division by zero.

It seems that in CMYK, if K is 1, the values of CMY don't matter, so we should set them explicitly to 0.

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