use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.
the class DefaultCropper method cropScreenshot.
@Override
public Screenshot cropScreenshot(BufferedImage image, Set<Coords> coordsToCompare) {
Coords cropArea = Coords.unity(coordsToCompare);
Coords imageIntersection = Coords.ofImage(image).intersection(cropArea);
if (imageIntersection.isEmpty()) {
return new Screenshot(image);
}
BufferedImage cropped = new BufferedImage(imageIntersection.width, imageIntersection.height, image.getType());
Graphics g = cropped.getGraphics();
g.drawImage(image, 0, 0, imageIntersection.width, imageIntersection.height, cropArea.x, cropArea.y, cropArea.x + imageIntersection.width, cropArea.y + imageIntersection.height, null);
g.dispose();
Screenshot screenshot = new Screenshot(cropped);
screenshot.setOriginShift(cropArea);
screenshot.setCoordsToCompare(setReferenceCoords(screenshot.getOriginShift(), coordsToCompare));
return screenshot;
}
use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.
the class IndentCropper method applyIndentMask.
protected Coords applyIndentMask(Coords origin, Coords mask) {
Coords spreadCoords = new Coords(0, 0);
spreadCoords.x = origin.x - mask.x;
spreadCoords.y = origin.y - mask.y;
spreadCoords.height = mask.y + origin.height + mask.height;
spreadCoords.width = mask.x + origin.width + mask.width;
return spreadCoords;
}
use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.
the class IndentCropper method createIndentMask.
protected Coords createIndentMask(Coords originCoords, BufferedImage image) {
Coords indentMask = new Coords(originCoords);
indentMask.x = Math.min(indent, originCoords.x);
indentMask.y = Math.min(indent, originCoords.y);
indentMask.width = Math.min(indent, image.getWidth() - originCoords.x - originCoords.width);
indentMask.height = Math.min(indent, image.getHeight() - originCoords.y - originCoords.height);
return indentMask;
}
use of ru.yandex.qatools.ashot.coordinates.Coords in project ashot by yandex-qatools.
the class ViewportPastingDecorator method shiftCoords.
private Set<Coords> shiftCoords(Set<Coords> coordsSet, Coords shootingArea) {
Set<Coords> shiftedCoords = new HashSet<>();
if (coordsSet != null) {
for (Coords coords : coordsSet) {
coords.y -= shootingArea.y;
shiftedCoords.add(coords);
}
}
return shiftedCoords;
}
Aggregations