ru.yandex.qatools.ashot.Screenshot Maven / Gradle / Ivy
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);
}
}