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

com.sksamuel.scrimage.composite.AlphaComposite Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
package com.sksamuel.scrimage.composite;

import com.sksamuel.scrimage.AwtImage;

import java.awt.*;

public class AlphaComposite implements Composite {

    private final double alpha;

    public AlphaComposite(double alpha) {
        this.alpha = alpha;
    }

    @Override
    public void apply(AwtImage src, AwtImage overlay) {
        Graphics2D g2 = (Graphics2D) src.awt().getGraphics();
        g2.setComposite(java.awt.AlphaComposite.SrcOver.derive((float) alpha));
        g2.drawImage(overlay.awt(), 0, 0, null);
        g2.dispose();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy