add isometric head renderer
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 30s
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 30s
This commit is contained in:
25
src/main/java/cc.fascinated/common/ImageUtils.java
Normal file
25
src/main/java/cc.fascinated/common/ImageUtils.java
Normal file
@ -0,0 +1,25 @@
|
||||
package cc.fascinated.common;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class ImageUtils {
|
||||
|
||||
/**
|
||||
* Resize an image.
|
||||
*
|
||||
* @param src the source image
|
||||
* @param scale the scale factor
|
||||
* @return the scaled image
|
||||
*/
|
||||
public static BufferedImage resize(@NotNull final BufferedImage src, final double scale) {
|
||||
BufferedImage scaled = new BufferedImage((int) (src.getWidth() * scale), (int) (src.getHeight() * scale), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = scaled.createGraphics();
|
||||
graphics.drawImage(src, AffineTransform.getScaleInstance(scale, scale), null);
|
||||
graphics.dispose();
|
||||
return scaled;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user