Most functions in Scrimage that deal with colours, accept an instance of java.awt.Color, however this class is limited.
Scrimage provides its own
com.sksamuel.scrimage.color.Color interface with implementations in the following color spaces:
Each of these implementations can be converted to the other. For example:
new RGBColor(255, 0, 255).toHSV();
new HSLColor(100f, 0.5f, 0.3f, 1f).toRGB();
When you want to create a colour to pass to a scrimage function, you can convert the Scrimage color type to an AWT color type via the
You can retrieve the
average() color value from
There is a full list of X11 defined colors in the
These can be used and converted to an AWT
Color when you need more than the defaults built into the JDK.
For example, to copy an image, setting all pixels to misty rose, we can use the following code: