![JAR search and dependency download from the Maven repository](/logo.png)
net.sourceforge.plantuml.png.PngSizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.png;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import net.sourceforge.plantuml.utils.Log;
public class PngSizer {
static public BufferedImage process(BufferedImage im, int minsize) {
if (minsize != Integer.MAX_VALUE) {
return resize(im, minsize);
}
return im;
}
static private BufferedImage resize(BufferedImage im, int minsize) {
Log.info("Resizing file to " + minsize);
if (im.getWidth() >= minsize) {
return im;
}
final BufferedImage newIm = new BufferedImage(minsize, im.getHeight(), BufferedImage.TYPE_INT_RGB);
final Graphics2D g2d = newIm.createGraphics();
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, newIm.getWidth(), newIm.getHeight());
final int delta = (minsize - im.getWidth()) / 2;
g2d.drawImage(im, delta, 0, null);
g2d.dispose();
return newIm;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy