Liz wrote:
If I'm displaying an image taken from a webcam, it typically takes up a lot of the screen. Is there a way to display it making it a different size, e.g. 30% of the screen width with setImage()?.
Think I cracked it, written a quick function so I can display the webcam image at 50% (Thanks Wololo for the advanced example) will make better later:
Code:
def setImageSize = { picture, psize ->
if (picture == null) {
setImage(null)
return
}
def image = java.awt.Toolkit.getDefaultToolkit().getImage("images/"+picture)
def width = image.getWidth()
def height = image.getHeight()
def frameBuffer = new java.awt.image.BufferedImage( (int)((width*psize)/10), (int)((height*psize)/10),java.awt.image.BufferedImage.TYPE_4BYTE_ABGR)
def sprite = javax.imageio.ImageIO.read(new File("images/"+picture))
java.awt.Graphics2D graphics = frameBuffer.createGraphics()
graphics.drawImage(sprite, 0, 0, (int)((width*psize)/10), (int)((height*psize)/10), null)
setImage(frameBuffer, false)
}
And in my test, calling it
Code:
setImageSize(TempImg,5)
all worked fine. The problem I get is copying it into the subcontrol_control script. It stops with the "Error java.lang.RuntimeException: Deprecated". This appears to be caused by having the setInfos(6... instead of setInfos(4..
So Doti is there a better way to do this that ver 6 likes or can I disable the error message as the script uses functions from API 6 so am not wanting to set the setInfos to 4?