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

com.applitools.eyes.FixedScaleProvider Maven / Gradle / Ivy

There is a newer version: 2.57
Show newest version
package com.applitools.eyes;

import com.applitools.utils.ArgumentGuard;
import com.applitools.utils.ImageUtils;

import java.awt.image.BufferedImage;

/**
 * Scale provider based on a fixed scale ratio.
 */
class FixedScaleProvider implements ScaleProvider {

    private final double scaleRatio;
    private final ScaleMethod scaleMethod;

    /**
     *
     * @param scaleRatio The scale ratio to use.
     * @param method The method used for scaling the image.
     */
    public FixedScaleProvider(double scaleRatio, ScaleMethod method) {
        ArgumentGuard.greaterThanZero(scaleRatio, "scaleRatio");
        ArgumentGuard.notNull(method, "method");
        this.scaleRatio = scaleRatio;
        this.scaleMethod = method;
    }

    /**
     *
     * @param scaleRatio The scale ratio to use.
     */
    public FixedScaleProvider(double scaleRatio) {
        this(scaleRatio, ScaleMethod.getDefault());
    }

    /**
     *
     * {@inheritDoc}
     */
    public double getScaleRatio() {
        return scaleRatio;
    }

    /**
     *
     * {@inheritDoc}
     */
    public BufferedImage scaleImage(BufferedImage image) {
        return ImageUtils.scaleImage(image, scaleMethod, scaleRatio);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy