Generates an image based on a screenshot and Mobile element
private BufferedImage generateImage(MobileElement element, File screenshot) { | |
BufferedImage qrCodeImage = null; | |
try { | |
BufferedImage fullImage = ImageIO.read(screenshot); | |
Point imageLocation = element.getLocation(); | |
int qrCodeImageWidth = element.getSize().getWidth(); | |
int qrCodeImageHeight = element.getSize().getHeight(); | |
int pointXPosition = imageLocation.getX(); | |
int pointYPosition = imageLocation.getY(); | |
qrCodeImage = fullImage.getSubimage(pointXPosition, pointYPosition, qrCodeImageWidth, qrCodeImageHeight); | |
ImageIO.write(qrCodeImage, "png", screenshot); | |
} catch (IOException e) { | |
log.error("Problem during the image generation", e); | |
} | |
return qrCodeImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
The complete code can be found at https://github.com/eliasnogueira/appium-read-qrcode