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)
{
super.paint(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) ,
(int)blue.reverse(color));

g.setColor(c);
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: ...
    (alt.comp.lang.borland-delphi)
  • 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, ...
    (microsoft.public.scripting.vbscript)
  • 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, ...
    (comp.lang.c)
  • Re: Which C tool?
    ... Flash Gordon wrote: ... The conversions in the opposite ...
    (comp.lang.c)
  • Re: Constrasting Color
    ... int green=originalColor.getGreen; ... Regards, ... Arnaud ... > If I have a Color object, is it possible to get a constrasting Color in ...
    (comp.lang.java.programmer)