BufferedImage and pixels color flipping

Hi all,

I was just wondering i want to be able to get a color rgb value of a
pixel at x,y then create another Color object (or int) that is the
opposite it, then paint a circle with the opposite color. Here is the
code i have so far

public class MyPanel extends JPanel

public void paint(Graphics g)
int color = mImage.getRGB(curX,curY);
ColorModel cm = mImage.getColorModel();

//get the Individual colors
Integer red = new Integer(cm.getRed(color));
Integer green = new Integer(cm.getGreen(color));
Integer blue = new Integer(cm.getBlue(color));

//see im stuck here how do i get the opposite of the color

//Color c = new
Color((int)red.reverse(color),(int)green.reverse(color) ,

g.fillOval(poi.getX(), poi.getY(), 5, 5);

Thanks in advance


Relevant Pages

  • Re: I have a line of code I need help with.
    ... >> It is simply that it would be nice to have the opposite of a Function ... and the language that comes to my mind is Algol ... PROC MyThing = (INT I, ... an explicit pointer dereference: ...
  • Re: How to reverse DatePart("y",Date) ?
    ... This would give an integer day of the year representing today but how ... do you achieve the opposite?. ... I am supplied with the int day or year, ... download from the Microsoft site, ...
  • Re: FAQ: int or long int?
    ... using int. ... In my experience it is the opposite. ... I did some messing around with a POWER system once which was natively ... 64-bit, on which it was noticably slower to use 64-bit values for everything, ...
  • Re: Which C tool?
    ... Flash Gordon wrote: ... The conversions in the opposite ...
  • Re: Constrasting Color
    ... > int green=originalColor.getGreen; ... >> If I have a Color object, is it possible to get a constrasting Color in ... Prev by Date: ...