Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2006

Tip: Looking for answers? Try searching our database.

BufferedImage and pixels color flipping

Thread view: 
placid - 03 Jan 2006 04:47 GMT
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
hiwa - 03 Jan 2006 06:07 GMT
BufferedImage#setRGB()
placid - 03 Jan 2006 06:25 GMT
Thats not what i want, all i need is the color at position x,y then
negate it or get a color that is visible on top of it (hence the
opposite color), then draw a oval at that x,y position (hence
g.fillOval(..) ).
Knute Johnson - 03 Jan 2006 06:34 GMT
> Thats not what i want, all i need is the color at position x,y then
> negate it or get a color that is visible on top of it (hence the
> opposite color), then draw a oval at that x,y position (hence
> g.fillOval(..) ).

Take the exclusive or of the int.

int c = color.getRGB();
c ^= c;

Signature

Knute Johnson
email s/nospam/knute/

John Bokma - 03 Jan 2006 06:36 GMT
> Thats not what i want,

This is not what I want, please read:
<http://groups.google.com/support/bin/answer.py?answer=14213>

Signature

John                               MexIT: http://johnbokma.com/mexit/
                          personal page:       http://johnbokma.com/
       Experienced programmer available:     http://castleamber.com/
           Happy Customers: http://castleamber.com/testimonials.html

placid - 05 Jan 2006 02:04 GMT
> > Thats not what i want,
>
[quoted text clipped - 6 lines]
>         Experienced programmer available:     http://castleamber.com/
>             Happy Customers: http://castleamber.com/testimonials.html

Thanks for the tip, which i already knew how to do, but google
complained that the page was not available at this time and only the
reply link at the bottom of the post worked !


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.