0

Hi all. I'm having a problem to represent or use a variable as an int.

Color c = new Color(255, 0, 0);
		int y = c.getRGB();

		for (int v = 0; v < h; v++) {
			for (int u = 0; u < w; u++) {
				int x = image.get(u, v);
				if (x == 255) {
					image.set(u, v, y);
				}
			}
		}

My variable c actually contains the values for a RGB colour. I want to use it as an int so I can set it to the colour I want.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by masijade
0

What do you mean "use it as an int". If you want the 0-255 individual values for the red, green, and blue, then maybe you should be using the getRed(), etc methods, rather than the getRGB method.

P.S. The API docs can be really helpful. Use them.

0

though i have not got you properly
but are you looking for

c.getRed();
c.getGreen();
c.getBlue();
c.getRGB();
0

The picture is an 8-bit grayscale picture. I need to change the white colour to red colour. How do I do that?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.