通过了解JPanel中一个点的坐标,我怎样才能得到它的颜色?
在Graphics2D
创建的BufferedImage
对象中绘制面板的内容,然后检索像素颜色:
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = image.createGraphics();
_mainPanel.paint(g2);
image.getColorModel().getRGB(pixel);
g2.dispose();