com.github.sarxos.webcam.util.ImageUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webcam-capture Show documentation
Show all versions of webcam-capture Show documentation
This library allows you to use your PC webcam, IP or network cameras directly from Java. It's compatible with most operating systems (Windows, Linux, MacOS).
package com.github.sarxos.webcam.util;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
public class ImageUtils {
public static BufferedImage premultiple(BufferedImage src) {
BufferedImage pre = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics2D g2 = pre.createGraphics();
g2.drawImage(src, 0, 0, null);
g2.dispose();
pre.flush();
return pre;
}
public static BufferedImage unpremultiple(BufferedImage pre) {
BufferedImage src = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = pre.createGraphics();
g2.drawImage(src, 0, 0, null);
g2.dispose();
src.flush();
return src;
}
}