All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.yandex.qatools.ashot.Screenshot Maven / Gradle / Ivy

There is a newer version: 1.5.4
Show newest version
package ru.yandex.qatools.ashot;

import ru.yandex.qatools.ashot.coordinates.Coords;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import static java.util.Arrays.asList;

/**
 * @author Pavel Zorin
 * @author Maksim Mukosey
 */

//todo docs
public class Screenshot implements Serializable {
    private static final long serialVersionUID = 1241241256734156872L;

    private transient BufferedImage image;
    private Set ignoredAreas = new HashSet<>();
    private Set coordsToCompare;

    public BufferedImage getImage() {
        return image;
    }

    public void setImage(BufferedImage image) {
        this.image = image;
    }

    public Screenshot(BufferedImage image) {
        this.image = image;
        this.coordsToCompare = new HashSet<>(asList(Coords.ofImage(image)));
    }

    public Set getCoordsToCompare() {
        return coordsToCompare;
    }

    public void setCoordsToCompare(Set coordsToCompare) {
        this.coordsToCompare = coordsToCompare;
    }

    public Set getIgnoredAreas() {
        return ignoredAreas;
    }

    public void setIgnoredAreas(Set ignoredAreas) {
        this.ignoredAreas = ignoredAreas;
    }

    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        ImageIO.write(image, "png", out);
    }

    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
        in.defaultReadObject();
        image = ImageIO.read(in);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy