Create  Edit  Diff  FrontPage  Index  Search  Changes  Login

The Backyard - GrabScreenIntoFile Diff

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

! rjbを利用して画面キャプチャを採る

require 'rjb'

Robot = Rjb::import 'java.awt.Robot'
Rectangle = Rjb::import('java.awt.Rectangle')
JFile = Rjb::import('java.io.File')
ImageIO = Rjb::import('javax.imageio.ImageIO')
robot = Robot.new
rect = Rectangle.new(0, 0, 640, 480)
bimage = robot.createScreenCapture(rect)
file = JFile.new('/tmp/capt.png')
ImageIO.write(bimage, "png", file)