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

fix switching RAW mode to RGB mode issue #62913

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KuaiDain
Copy link

fixes #62894

return next_power_of_2(MAX(255, color.components[idx] * 255.0)) - 1;

when result of color.components[idx] * 255.0 beyond 255, this issue will happen, so i modified this function as other mode

@KuaiDain KuaiDain requested a review from a team as a code owner July 11, 2022 14:40
@YuriSizov YuriSizov added this to the 4.0 milestone Jul 11, 2022
@KoBeWi
Copy link
Member

KoBeWi commented Jul 11, 2022

Doesn't this always clamp the value to 255? It means your color is truncated when you switch from RAW to RGB. Not sure if it's desired 🤔

@fire
Copy link
Member

fire commented Jul 11, 2022

You can have different "intensity" value that is multiplied with a rgba8 to store the original value, but converting values outside of 0 to 1 to RGBA8 is a lossy conversion.

Would like some opinions.

@KuaiDain
Copy link
Author

thanks for your advice
i think this issue again, when i change value in RGB mode, it will store value/255.0 back to color, so rgba is in range 0 to 1,

Color ColorModeRGB::get_color() const {
	Vector<float> values = color_picker->get_active_slider_values();
	Color color;
	for (int i = 0; i < 4; i++) {
		color.components[i] = values[i] / 255.0;
	}
	return color;
}

except RAW mode, other mode do a calculation, then store back to color

Color ColorModeRAW::get_color() const {
	Vector<float> values = color_picker->get_active_slider_values();
	Color color;
	for (int i = 0; i < 4; i++) {
		color.components[i] = values[i];
	}
	return color;
}

float slider_max[4] = { 100, 100, 100, 1 }; this line cause that we can store value beyond 1 back to color, so i change it to float slider_max[4] = { 1, 1, 1, 1 };

@AThousandShips
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switching to RAW mode and then to RGB will change slider max value until refreshed
6 participants