Skip to content

Tag: colors

How to convert RGB color to grayscale in Java

I’m trying to create a method that converts a given java.awt.Color color to grayscale. Here’s what I have right now: However, when I call this method, it seems to be returning the color black every single time, regardless of the input color. How do I fix this? Answer The float components are in the range of [0.0, 1.0]. You are

Java: How got check colors from an invisible panel

is it possible to read colors of you mouse position of an invisible panel? I want to have an “invisible overlay” with an color coded image. I used the Robot class to get my mouse position and the color. It works fine on my visible image, but if I set the image to invisible, it completely gets ignored. Is there

Compute hex color code for an arbitrary string

Heading Is there a way to map an arbitrary string to a HEX COLOR code. I tried to compute the HEX number for string using string hashcode. Now I need to convert this hex number to six digits which are in HEX color code range. Any suggestions ? Answer If you don’t really care about the “meaning” of the color