Leonard
Leonard

Reputation: 561

How to get the colour of a applet viewer pixel in Java?

I have drawn any picture, used Graphics 2D. How do I get the colour of a pixel at x, y? getPixelColor don't work, because this method get pixel from screen, not applet viewer coordinates.

Upvotes: 1

Views: 1119

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

  1. Draw the picture to the Graphics of a BufferedImage
  2. Draw the image to the Graphics2D.
  3. To get the color of any pixel, call BufferedImage.getRGB(x,y) or variants (check the docs.).

Upvotes: 1

Related Questions