← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #626490]: Errors happen when Android screen is horizontal

 

Question #626490 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/626490

Action gave more information on the question:
Hello, Sir, I have written some codes to fix this problem, and it works fine on my program. This picture rotate function will take about 0.16s--0.32s, I think it's acceptable. 
     I will test it on ADBDevice.java if I can figure out how. Plan to do it in these two days.

    These are the codes:

		BufferedImage oldImage = ImageIO.read(stdout);
		int newWidth = oldImage.getHeight(null);
		int newHeight = oldImage.getWidth(null);
		BufferedImage image = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_BGR);
		Graphics2D g2 = image.createGraphics();
		g2.rotate(Math.PI * 1.5, newHeight / 2, newWidth / 2);
		g2.translate((newWidth - newHeight) / 2, (newWidth - newHeight) / 2);
		g2.drawImage(oldImage, 0, 0, newHeight, newWidth, null);
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		ImageIO.write(image, "png", out);
		stdout = new ByteArrayInputStream(out.toByteArray());

    Hope these could help a little for this project.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.