fb0内的RAW数据不是每个设备都一样的试试这个 public ImageIcon getImageIcon(String targetNum) { try { // long start = System.currentTimeMillis(); RawImage rawImage = device.getScreenshot(); // long end = System.currentTimeMillis(); // System.out.println("获取屏幕时间:" + (end - start) + "-毫秒"); BufferedImage image = new BufferedImage(rawImage.width, rawImage.height, BufferedImage.TYPE_INT_RGB); int index = 0; int IndexInc = rawImage.bpp >> 3; for (int y = 0; y < rawImage.height; y++) { for (int x = 0; x < rawImage.width; x++) { int value = rawImage.getARGB(index); index += IndexInc; image.setRGB(x, y, value); } } return new ImageIcon(image); } catch (Exception e) { e.printStackTrace(); } return null; }
public ImageIcon getImageIcon(String targetNum) {
try {
// long start = System.currentTimeMillis();
RawImage rawImage = device.getScreenshot();
// long end = System.currentTimeMillis();
// System.out.println("获取屏幕时间:" + (end - start) + "-毫秒");
BufferedImage image = new BufferedImage(rawImage.width,
rawImage.height, BufferedImage.TYPE_INT_RGB);
int index = 0;
int IndexInc = rawImage.bpp >> 3;
for (int y = 0; y < rawImage.height; y++) {
for (int x = 0; x < rawImage.width; x++) {
int value = rawImage.getARGB(index);
index += IndexInc;
image.setRGB(x, y, value);
}
}
return new ImageIcon(image); } catch (Exception e) {
e.printStackTrace();
}
return null;
}