java.lang.Object
io.github.stanio.xbrz.Xbrz
Defines the main API for xBRZ scaling. Instances are configured with specific
scale factor, color blending type (alpha vs. no alpha) and color distance function. A single instance could be used to
scale multiple images concurrently.
Sample usage:
import java.awt.image.BufferedImage; BufferedImage source = ...; int srcWidth = source.getWidth(); int srcHeight = source.getHeight(); int[] srcPixels = source.getRGB(0, 0, srcWidth, srcHeight, null, 0, srcWidth); int factor = 2; int destWidth = srcWidth * factor; int destHeight = srcHeight * factor; boolean hasAlpha = source.getColorModel().hasAlpha(); int[] destPixels = Xbrz.scaleImage(factor, hasAlpha, srcPixels, null, srcWidth, srcHeight); BufferedImage scaled = new BufferedImage(destWidth, destHeight, hasAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); scaled.setRGB(0, 0, destWidth, destHeight, destPixels, 0, destWidth);
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionXbrz
(int factor) Constructs a new xBRZ scaler.Xbrz
(int factor, boolean withAlpha) Xbrz
(int factor, boolean withAlpha, Xbrz.ScalerCfg cfg) Xbrz
(int factor, boolean withAlpha, Xbrz.ScalerCfg cfg, ColorDistance colorDistance) -
Method Summary
Modifier and TypeMethodDescriptionint
factor()
The factor thisXbrz
instance applies when scaling images.int
scale()
factor
alias.int[]
scaleImage
(int[] src, int[] trg, int srcWidth, int srcHeight) Scales thesrc
pixels to thetrg
buffer.void
scaleImage
(int[] src, int[] trg, int srcWidth, int srcHeight, int yFirst, int yLast) static int[]
scaleImage
(int factor, boolean hasAlpha, int[] src, int[] trg, int srcWidth, int srcHeight) new Xbrz(factor, hasAlpha).scaleImage(src, trg, srcWidth, srcHeight)
-
Constructor Details
-
Xbrz
public Xbrz(int factor) Constructs a new xBRZ scaler.- Parameters:
factor
- the scale factor to apply- Throws:
IllegalArgumentException
- if the specified scale factor is < 2 or > 6
-
Xbrz
public Xbrz(int factor, boolean withAlpha) -
Xbrz
-
Xbrz
-
-
Method Details
-
factor
public int factor()The factor thisXbrz
instance applies when scaling images.- Returns:
- The configured scaling factor
-
scale
public int scale()factor
alias.- See Also:
-
scaleImage
public int[] scaleImage(int[] src, int[] trg, int srcWidth, int srcHeight) Scales thesrc
pixels to thetrg
buffer.The pixels are expected to be packed as ARGB
int
(32-bit) values. -
scaleImage
public void scaleImage(int[] src, int[] trg, int srcWidth, int srcHeight, int yFirst, int yLast) -
scaleImage
public static int[] scaleImage(int factor, boolean hasAlpha, int[] src, int[] trg, int srcWidth, int srcHeight) new Xbrz(factor, hasAlpha).scaleImage(src, trg, srcWidth, srcHeight)
- See Also:
-