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

Incorrect color conversion? #6

Open
themightyoarfish opened this issue May 1, 2020 · 3 comments
Open

Incorrect color conversion? #6

themightyoarfish opened this issue May 1, 2020 · 3 comments

Comments

@themightyoarfish
Copy link

b2 = ceil(((float)b1/65536)*(float)256);

The code multiplies by 256 here, should it not be 255?

@murtiad
Copy link
Owner

murtiad commented Jun 15, 2020

Hi @themightyoarfish. CMIIW but for the conversion I used 256 instead of 255 because there are 256 available grey shades (0-255)

@themightyoarfish
Copy link
Author

Yes, but the highest value is 255. So if the expression results in something between 0 and 1.0, we have to multiply by the largest value, no?
Maybe I'm misunderstanding something but it looks as if this code could generate color values of 256 which would be invalid for 8 bit rgb.

@murtiad
Copy link
Owner

murtiad commented Jun 15, 2020

I see your point and I think you're right. If we have a max las RGB value of 65535 this would indeed cause the code to generate a value of 256 in 8 bit which would be incorrect. I'll modify the code accordingly, thanks a lot for pointing out this important detail!

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

2 participants