简体   繁体   English

如何在Java中获取小程序查看器像素的颜色?

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

I have drawn any picture, used Graphics 2D. 我已经绘制了任何图片,使用了Graphics 2D。 How do I get the colour of a pixel at x, y? 如何获得x,y处像素的颜色? getPixelColor don't work, because this method get pixel from screen, not applet viewer coordinates. getPixelColor不起作用,因为此方法从屏幕而不是applet查看器坐标获取像素。

  1. Draw the picture to the Graphics of a BufferedImage 将图片绘制到BufferedImageGraphics
  2. Draw the image to the Graphics2D . 将图像绘制到Graphics2D
  3. To get the color of any pixel, call BufferedImage.getRGB(x,y) or variants (check the docs.). 要获取任何像素的颜色,请调用BufferedImage.getRGB(x,y)或变体(请检查文档。)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM