Brixomatic commented on a change in pull request #114:
URL: https://github.com/apache/commons-imaging/pull/114#discussion_r548922875
##########
File path: src/main/java/org/apache/commons/imaging/color/ColorConversions.java
##########
@@ -643,28 +602,30 @@ private static int convertRGBtoRGB(int red, int green,
int blue) {
return rgb;
}
+ private static int convertRGBtoRGB(final Color color) {
+ return color.getRGB() | 0xff << 24; // alpha channel always opaque
+ }
+
public static ColorCieLch convertCIELabtoCIELCH(final ColorCieLab cielab) {
return convertCIELabtoCIELCH(cielab.L, cielab.a, cielab.b);
}
public static ColorCieLch convertCIELabtoCIELCH(final double L, final
double a, final double b) {
- double var_H = Math.atan2(b, a); // Quadrant by signs
+ // atan2(y,x) returns atan(y/x)
+ final double atanba = Math.atan2(b, a); // Quadrant by signs
- if (var_H > 0) {
- var_H = (var_H / Math.PI) * 180.0;
- } else {
- var_H = 360 - radian_2_degree(Math.abs(var_H));
- }
+ final double h = atanba > 0 //
+ ? Math.toDegrees(atanba) //
+ : Math.toDegrees(atanba) + 360;
Review comment:
We can very well use java.lang.Math, instead of doing it step by step.
Also reads better.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]