/** * Convert BufferredImage to RGBPicture * * @param source BufferedImage of TYPE_3_BYTE_BGR */ public RGBPicture fromBufferedImage(BufferedImage source) { return fromBufferedImage(source, null); }
/** * Convert RGBPicture to BufferedImage, minimizing object allocation * * @param picture RGBPicture to convert * @return new BufferedImage. */ public BufferedImage toBufferedImage(RGBPicture picture) { return toBufferedImage(picture, null); }
public static void main(String[] args) throws IOException { JFrame frame = new JFrame("ScreenShot"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel label = new JLabel(); label.setPreferredSize(new Dimension(width, height)); frame.getContentPane().add(label); frame.pack(); frame.setVisible(true); ScreenCapture capture = ScreenCaptureFactory.getScreenCapture(); Rectangle bounds = new Rectangle(0, 0, width, height); RGBPictureConverter converter = new RGBPictureConverter(); while(true) { long start = System.nanoTime(); RGBPicture img = capture.createScreenCapture(bounds); System.out.println((System.nanoTime() - start) / 1e9); ImageIcon icon = new ImageIcon(converter.toBufferedImage(img)); label.setIcon(icon); img.delete(); try { Thread.sleep(100); } catch (InterruptedException e) { } } }
public static void main(String[] args) throws IOException { JFrame frame = new JFrame("ScreenShot"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel label = new JLabel(); label.setPreferredSize(new Dimension(width, height)); frame.getContentPane().add(label); frame.pack(); frame.setVisible(true); ScreenCapture capture = ScreenCaptureFactory.getScreenCapture(); Rectangle bounds = new Rectangle(0, 0, width, height); RGBPictureConverter converter = new RGBPictureConverter(); while(true) { long start = System.nanoTime(); RGBPicture img = capture.createScreenCapture(bounds); System.out.println((System.nanoTime() - start) / 1e9); ImageIcon icon = new ImageIcon(converter.toBufferedImage(img)); label.setIcon(icon); img.delete(); try { Thread.sleep(100); } catch (InterruptedException e) { } } }
/** * Convert BufferredImage to RGBPicture * * @param source BufferedImage of TYPE_3_BYTE_BGR */ public RGBPicture fromBufferedImage(BufferedImage source) { return fromBufferedImage(source, null); }
/** * Convert RGBPicture to BufferedImage, minimizing object allocation * * @param picture RGBPicture to convert * @return new BufferedImage. */ public BufferedImage toBufferedImage(RGBPicture picture) { return toBufferedImage(picture, null); }
@Override public RGBPicture createScreenCapture(Rectangle bounds) { return converter.fromBufferedImage(robot.createScreenCapture(bounds)); }
/** * Convert YUVPicture to BufferedImage, minimizing object allocation * * @param picture YUVPicture to convert * @param imageToPack Image to output to. If picture.size() != imageToPack.size() then a new BufferedImage is allocated * @return imageToPack if sizes match, new BufferedImage otherwise. */ public BufferedImage toBufferedImage(YUVPicture picture, BufferedImage imageToPack) { RGBPicture rgb = picture.toRGB(); BufferedImage img = rgbPictureConverter.toBufferedImage(rgb, imageToPack); rgb.delete(); return img; }
@Override public RGBPicture createScreenCapture(Rectangle bounds) { return converter.fromBufferedImage(robot.createScreenCapture(bounds)); }
/** * Convert YUVPicture to BufferedImage, minimizing object allocation * * @param picture YUVPicture to convert * @param imageToPack Image to output to. If picture.size() != imageToPack.size() then a new BufferedImage is allocated * @return imageToPack if sizes match, new BufferedImage otherwise. */ public BufferedImage toBufferedImage(YUVPicture picture, BufferedImage imageToPack) { RGBPicture rgb = picture.toRGB(); BufferedImage img = rgbPictureConverter.toBufferedImage(rgb, imageToPack); rgb.delete(); return img; }
public YUVPicture fromBufferedImage(BufferedImage source, YUVSubsamplingType samplingType) { RGBPicture rgb = rgbPictureConverter.fromBufferedImage(source); YUVPicture target = rgb.toYUV(samplingType); rgb.delete(); return target; } }
public YUVPicture fromBufferedImage(BufferedImage source, YUVSubsamplingType samplingType) { RGBPicture rgb = rgbPictureConverter.fromBufferedImage(source); YUVPicture target = rgb.toYUV(samplingType); rgb.delete(); return target; } }