Search in sources :

Example 6 with Coords

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;
}
Also used : Screenshot(ru.yandex.qatools.ashot.Screenshot) Coords.setReferenceCoords(ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords) Coords(ru.yandex.qatools.ashot.coordinates.Coords) BufferedImage(java.awt.image.BufferedImage)

Example 7 with Coords

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;
}
Also used : Coords.setReferenceCoords(ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords) Coords(ru.yandex.qatools.ashot.coordinates.Coords)

Example 8 with Coords

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;
}
Also used : Coords.setReferenceCoords(ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords) Coords(ru.yandex.qatools.ashot.coordinates.Coords)

Example 9 with Coords

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;
}
Also used : Coords(ru.yandex.qatools.ashot.coordinates.Coords) HashSet(java.util.HashSet)

Aggregations

Coords (ru.yandex.qatools.ashot.coordinates.Coords)9 Screenshot (ru.yandex.qatools.ashot.Screenshot)4 Coords.setReferenceCoords (ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords)4 Test (org.junit.Test)3 ImageDiff (ru.yandex.qatools.ashot.comparison.ImageDiff)2 BufferedImage (java.awt.image.BufferedImage)1 HashSet (java.util.HashSet)1