This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
commit 20f22a77dcf8977890c644d8eae106dfafcac2ea Author: Gary Gregory <[email protected]> AuthorDate: Sun Jan 4 05:48:57 2026 -0500 Javadoc --- .../imaging/formats/gif/GifImageParser.java | 1 - .../formats/jpeg/iptc/PhotoshopApp13Data.java | 36 +++++++++++++ .../commons/imaging/formats/pcx/PcxConstants.java | 8 +++ .../imaging/formats/pcx/PcxImageParser.java | 60 +++++++++++++--------- .../imaging/formats/pcx/PcxImagingParameters.java | 39 ++++++++++++++ .../commons/imaging/formats/png/PhysicalScale.java | 2 + .../PhotometricInterpreterBiLevel.java | 13 +++++ .../PhotometricInterpreterCieLab.java | 16 +++++- .../PhotometricInterpreterCmyk.java | 17 ++++-- .../PhotometricInterpreterLogLuv.java | 9 ++++ .../PhotometricInterpreterPalette.java | 3 ++ .../PhotometricInterpreterRgb.java | 12 +++++ .../PhotometricInterpreterYCbCr.java | 20 ++++++++ .../imaging/palette/MedianCutQuantizer.java | 9 ++++ .../commons/imaging/palette/PaletteFactory.java | 38 ++++++++++++++ 15 files changed, 254 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java index d33cc362..ae95e254 100644 --- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java @@ -486,7 +486,6 @@ public class GifImageParser extends AbstractImageParser<GifImagingParameters> im /** * Extracts embedded XML metadata as XML string. - * <p> * * @param byteSource File containing image data. * @param params Map of optional parameters, defined in ImagingConstants. diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/PhotoshopApp13Data.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/PhotoshopApp13Data.java index e88c5073..86aa9d58 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/PhotoshopApp13Data.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/PhotoshopApp13Data.java @@ -21,21 +21,42 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +/** + * Photoshop APP13 segment data containing IPTC records and blocks. + */ public class PhotoshopApp13Data { private final boolean forceUtf8Encoding; private final List<IptcRecord> records; private final List<IptcBlock> rawBlocks; + /** + * Constructs Photoshop APP13 data. + * + * @param records the IPTC records. + * @param rawBlocks the raw IPTC blocks. + */ public PhotoshopApp13Data(final List<IptcRecord> records, final List<IptcBlock> rawBlocks) { this(records, rawBlocks, false); } + /** + * Constructs Photoshop APP13 data. + * + * @param records the IPTC records. + * @param rawBlocks the raw IPTC blocks. + * @param forceUtf8Encoding whether to force UTF-8 encoding. + */ public PhotoshopApp13Data(final List<IptcRecord> records, final List<IptcBlock> rawBlocks, final boolean forceUtf8Encoding) { this.rawBlocks = rawBlocks == null ? Collections.emptyList() : Collections.unmodifiableList(rawBlocks); this.records = records == null ? Collections.emptyList() : Collections.unmodifiableList(records); this.forceUtf8Encoding = forceUtf8Encoding; } + /** + * Gets the non-IPTC blocks. + * + * @return list of non-IPTC blocks. + */ public List<IptcBlock> getNonIptcBlocks() { final List<IptcBlock> result = new ArrayList<>(); for (final IptcBlock block : rawBlocks) { @@ -46,14 +67,29 @@ public class PhotoshopApp13Data { return result; } + /** + * Gets the raw IPTC blocks. + * + * @return list of raw blocks. + */ public List<IptcBlock> getRawBlocks() { return new ArrayList<>(rawBlocks); } + /** + * Gets the IPTC records. + * + * @return list of IPTC records. + */ public List<IptcRecord> getRecords() { return new ArrayList<>(records); } + /** + * Checks if UTF-8 encoding is forced. + * + * @return true if UTF-8 encoding is forced, false otherwise. + */ public boolean isForceUtf8Encoding() { return forceUtf8Encoding; } diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java index 1aaa69f4..f3889879 100644 --- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java @@ -12,10 +12,18 @@ * limitations under the License. * under the License. */ + package org.apache.commons.imaging.formats.pcx; +/** + * PCX format constants. + */ public final class PcxConstants { + + /** PCX compression: Uncompressed. */ public static final int PCX_COMPRESSION_UNCOMPRESSED = 0; + + /** PCX compression: RLE (Run-Length Encoding). */ public static final int PCX_COMPRESSION_RLE = 1; private PcxConstants() { diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java index 9e2598c3..d6dd7f5c 100644 --- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java @@ -49,6 +49,9 @@ import org.apache.commons.imaging.bytesource.ByteSource; import org.apache.commons.imaging.common.Allocator; import org.apache.commons.imaging.common.ImageMetadata; +/** + * Parses PCX (PC Paintbrush) images. + */ public class PcxImageParser extends AbstractImageParser<PcxImagingParameters> { // ZSoft's official spec is at [BROKEN URL] http://www.qzx.com/pc-gpe/pcx.txt // (among other places) but it's pretty thin. The fileformat.fine document @@ -68,32 +71,43 @@ public class PcxImageParser extends AbstractImageParser<PcxImagingParameters> { public static final int ENCODING_RLE = 1; public static final int PALETTE_INFO_COLOR = 1; public static final int PALETTE_INFO_GRAYSCALE = 2; - public final int manufacturer; // Always 10 = ZSoft .pcx - public final int version; // 0 = PC Paintbrush 2.5 - // 2 = PC Paintbrush 2.8 with palette - // 3 = PC Paintbrush 2.8 w/o palette - // 4 = PC Paintbrush for Windows - // 5 = PC Paintbrush >= 3.0 - public final int encoding; // 0 = very old uncompressed format, 1 = .pcx - // run length encoding - public final int bitsPerPixel; // Bits ***PER PLANE*** for each pixel - public final int xMin; // window + /** Always 10 = ZSoft .pcx. */ + public final int manufacturer; + /** + * Version: 0 = PC Paintbrush 2.5, 2 = PC Paintbrush 2.8 with palette, 3 = PC Paintbrush 2.8 w/o palette, 4 = PC Paintbrush for Windows, 5 = PC + * Paintbrush >= 3.0. + */ + public final int version; + /** Encoding: 0 = very old uncompressed format, 1 = .pcx run length encoding. */ + public final int encoding; + /** Bits ***PER PLANE*** for each pixel. */ + public final int bitsPerPixel; + /** Window xMin. */ + public final int xMin; + /** Window yMin. */ public final int yMin; + /** Window xMax. */ public final int xMax; + /** Window yMax. */ public final int yMax; - public final int hDpi; // horizontal dpi - public final int vDpi; // vertical dpi - public final int[] colormap; // palette for <= 16 colors - public final int reserved; // Always 0 - public final int nPlanes; // Number of color planes - public final int bytesPerLine; // Number of bytes per scanline plane, - // must be an even number. - public final int paletteInfo; // 1 = Color/BW, 2 = Grayscale, ignored in - // Paintbrush IV/IV+ - public final int hScreenSize; // horizontal screen size, in pixels. - // PaintBrush >= IV only. - public final int vScreenSize; // vertical screen size, in pixels. - // PaintBrush >= IV only. + /** Horizontal dpi. */ + public final int hDpi; + /** Vertical dpi. */ + public final int vDpi; + /** Palette for <= 16 colors. */ + public final int[] colormap; + /** Always 0. */ + public final int reserved; + /** Number of color planes. */ + public final int nPlanes; + /** Number of bytes per scanline plane, must be an even number. */ + public final int bytesPerLine; + /** 1 = Color/BW, 2 = Grayscale, ignored in Paintbrush IV/IV+. */ + public final int paletteInfo; + /** Horizontal screen size, in pixels. PaintBrush >= IV only. */ + public final int hScreenSize; + /** Vertical screen size, in pixels. PaintBrush >= IV only. */ + public final int vScreenSize; PcxHeader(final int manufacturer, final int version, final int encoding, final int bitsPerPixel, final int xMin, final int yMin, final int xMax, final int yMax, final int hDpi, final int vDpi, final int[] colormap, final int reserved, final int nPlanes, final int bytesPerLine, diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImagingParameters.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImagingParameters.java index 73eae1e1..e0b8bc68 100644 --- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImagingParameters.java +++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImagingParameters.java @@ -24,32 +24,71 @@ import org.apache.commons.imaging.ImagingParameters; */ public class PcxImagingParameters extends ImagingParameters<PcxImagingParameters> { + /** + * Constructs a new instance. + */ + public PcxImagingParameters() { + } + private int planes = -1; private int bitDepth = -1; private int compression = PcxConstants.PCX_COMPRESSION_UNCOMPRESSED; + /** + * Gets the bit depth. + * + * @return the bit depth. + */ public int getBitDepth() { return bitDepth; } + /** + * Gets the compression type. + * + * @return the compression type. + */ public int getCompression() { return compression; } + /** + * Gets the number of planes. + * + * @return the number of planes. + */ public int getPlanes() { return planes; } + /** + * Sets the bit depth. + * + * @param bitDepth the bit depth. + * @return this instance. + */ public PcxImagingParameters setBitDepth(final int bitDepth) { this.bitDepth = bitDepth; return asThis(); } + /** + * Sets the compression type. + * + * @param compression the compression type. + * @return this instance. + */ public PcxImagingParameters setCompression(final int compression) { this.compression = compression; return asThis(); } + /** + * Sets the number of planes. + * + * @param planes the number of planes. + * @return this instance. + */ public PcxImagingParameters setPlanes(final int planes) { this.planes = planes; return asThis(); diff --git a/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java b/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java index 5bf1c6b0..79509318 100644 --- a/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java +++ b/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java @@ -22,6 +22,8 @@ package org.apache.commons.imaging.formats.png; public final class PhysicalScale { private static final int METER_UNITS = 1; private static final int RADIAN_UNITS = 2; + + /** Undefined physical scale. */ public static final PhysicalScale UNDEFINED = createFromMeters(-1.0, -1.0); public static PhysicalScale createFromMeters(final double x, final double y) { diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java index 63eecb13..0637eb1a 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java @@ -21,11 +21,24 @@ import java.io.IOException; import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.ImageBuilder; +/** + * Photometric interpreter for bi-level (black and white) images. + */ public class PhotometricInterpreterBiLevel extends AbstractPhotometricInterpreter { private final boolean invert; // private final int bitsPerPixel; + /** + * Constructs a new bi-level photometric interpreter. + * + * @param samplesPerPixel the samples per pixel. + * @param bitsPerSample the bits per sample. + * @param predictor the predictor. + * @param width the image width. + * @param height the image height. + * @param invert whether to invert the colors. + */ public PhotometricInterpreterBiLevel(final int samplesPerPixel, final int[] bitsPerSample, final int predictor, final int width, final int height, final boolean invert) { super(samplesPerPixel, bitsPerSample, predictor, width, height); diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java index dc2280b3..c6af7f47 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.commons.imaging.formats.tiff.photometricinterpreters; import java.io.IOException; @@ -22,7 +23,20 @@ import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.color.ColorConversions; import org.apache.commons.imaging.common.ImageBuilder; +/** + * Photometric interpreter for CIE L*a*b* color space images. + */ public class PhotometricInterpreterCieLab extends AbstractPhotometricInterpreter { + + /** + * Constructs a new CIE L*a*b* photometric interpreter. + * + * @param samplesPerPixel the samples per pixel. + * @param bitsPerSample the bits per sample. + * @param predictor the predictor. + * @param width the image width. + * @param height the image height. + */ public PhotometricInterpreterCieLab(final int samplesPerPixel, final int[] bitsPerSample, final int predictor, final int width, final int height) { super(samplesPerPixel, bitsPerSample, predictor, width, height); } @@ -32,9 +46,7 @@ public class PhotometricInterpreterCieLab extends AbstractPhotometricInterpreter final int cieL = samples[0]; final int cieA = (byte) samples[1]; final int cieB = (byte) samples[2]; - final int rgb = ColorConversions.convertCieLabToArgbTest(cieL, cieA, cieB); imageBuilder.setRgb(x, y, rgb); } - } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java index 0e85d8d3..d96e69ea 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.commons.imaging.formats.tiff.photometricinterpreters; import java.io.IOException; @@ -22,21 +23,31 @@ import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.color.ColorConversions; import org.apache.commons.imaging.common.ImageBuilder; +/** + * Photometric interpreter for CMYK color space images. + */ public class PhotometricInterpreterCmyk extends AbstractPhotometricInterpreter { + + /** + * Constructs a new CMYK photometric interpreter. + * + * @param samplesPerPixel the samples per pixel. + * @param bitsPerSample the bits per sample. + * @param predictor the predictor. + * @param width the image width. + * @param height the image height. + */ public PhotometricInterpreterCmyk(final int samplesPerPixel, final int[] bitsPerSample, final int predictor, final int width, final int height) { super(samplesPerPixel, bitsPerSample, predictor, width, height); } @Override public void interpretPixel(final ImageBuilder imageBuilder, final int[] samples, final int x, final int y) throws ImagingException, IOException { - final int sc = samples[0]; final int sm = samples[1]; final int sy = samples[2]; final int sk = samples[3]; - final int rgb = ColorConversions.convertCmykToRgb(sc, sm, sy, sk); imageBuilder.setRgb(x, y, rgb); } - } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java index 184f6df2..d1115f49 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java @@ -46,6 +46,15 @@ public class PhotometricInterpreterLogLuv extends AbstractPhotometricInterpreter public float z; } + /** + * Constructs a new LogLuv photometric interpreter. + * + * @param samplesPerPixel the samples per pixel. + * @param bitsPerSample the bits per sample. + * @param predictor the predictor. + * @param width the image width. + * @param height the image height. + */ public PhotometricInterpreterLogLuv(final int samplesPerPixel, final int[] bitsPerSample, final int predictor, final int width, final int height) { super(samplesPerPixel, bitsPerSample, predictor, width, height); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java index 4549fdfd..1929222b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java @@ -25,6 +25,9 @@ import org.apache.commons.imaging.common.AllocationRequestException; import org.apache.commons.imaging.common.Allocator; import org.apache.commons.imaging.common.ImageBuilder; +/** + * Photometric interpreter for palette-based (indexed color) images. + */ public final class PhotometricInterpreterPalette extends AbstractPhotometricInterpreter { /** diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java index 579e7e02..e75bdd77 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java @@ -21,7 +21,19 @@ import java.io.IOException; import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.ImageBuilder; +/** + * Photometric interpreter for RGB color space images. + */ public class PhotometricInterpreterRgb extends AbstractPhotometricInterpreter { + /** + * Constructs a new RGB photometric interpreter. + * + * @param samplesPerPixel the samples per pixel. + * @param bitsPerSample the bits per sample. + * @param predictor the predictor. + * @param width the image width. + * @param height the image height. + */ public PhotometricInterpreterRgb(final int samplesPerPixel, final int[] bitsPerSample, final int predictor, final int width, final int height) { super(samplesPerPixel, bitsPerSample, predictor, width, height); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java index e126c316..140853bd 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java @@ -21,6 +21,9 @@ import java.io.IOException; import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.ImageBuilder; +/** + * Photometric interpreter for YCbCr (YUV) color space images. + */ public class PhotometricInterpreterYCbCr extends AbstractPhotometricInterpreter { /** @@ -47,10 +50,27 @@ public class PhotometricInterpreterYCbCr extends AbstractPhotometricInterpreter return alpha << 24 | r << 16 | g << 8 | b << 0; } + /** + * Limits a value to a specified range. + * + * @param value the value to limit. + * @param min the minimum value. + * @param max the maximum value. + * @return the limited value. + */ public static int limit(final int value, final int min, final int max) { return Math.min(max, Math.max(min, value)); } + /** + * Constructs a new YCbCr photometric interpreter. + * + * @param samplesPerPixel the samples per pixel. + * @param bitsPerSample the bits per sample. + * @param predictor the predictor. + * @param width the image width. + * @param height the image height. + */ public PhotometricInterpreterYCbCr(final int samplesPerPixel, final int[] bitsPerSample, final int predictor, final int width, final int height) { super(samplesPerPixel, bitsPerSample, predictor, width, height); } diff --git a/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java b/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java index e89f9a9d..238c5a9a 100644 --- a/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java +++ b/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java @@ -97,6 +97,15 @@ public class MedianCutQuantizer { return colorMap; } + /** + * Processes an image to create a palette using median cut quantization. + * + * @param image the image to process. + * @param maxColors the maximum number of colors in the palette. + * @param medianCut the median cut algorithm to use. + * @return the generated palette. + * @throws ImagingException if an imaging error occurs. + */ public Palette process(final BufferedImage image, final int maxColors, final MedianCut medianCut) throws ImagingException { final Map<Integer, ColorCount> colorMap = groupColors(image, maxColors); diff --git a/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java b/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java index 8ea7c4b9..22e78e03 100644 --- a/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java +++ b/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java @@ -49,8 +49,21 @@ public class PaletteFactory { private static final Logger LOGGER = Logger.getLogger(PaletteFactory.class.getName()); + /** Number of color components (in bits). */ public static final int COMPONENTS = 3; // in bits + /** + * Constructs a new instance. + */ + public PaletteFactory() { + } + + /** + * Counts the number of distinct transparent colors in an image. + * + * @param src the source image. + * @return 0 if no transparent colors, 1 if one transparent color, 2 if more than one. + */ public int countTransparentColors(final BufferedImage src) { final ColorModel cm = src.getColorModel(); if (!cm.hasAlpha()) { @@ -82,6 +95,12 @@ public class PaletteFactory { return 1; } + /** + * Counts the number of distinct transparent colors in an RGB array. + * + * @param rgbs the RGB values. + * @return 0 if no transparent colors, 1 if one transparent color, 2 if more than one. + */ public int countTrasparentColors(final int[] rgbs) { int first = -1; @@ -272,10 +291,23 @@ public class PaletteFactory { return sum; } + /** + * Checks if the image has transparency. + * + * @param src the source image. + * @return true if the image has any transparency, false otherwise. + */ public boolean hasTransparency(final BufferedImage src) { return hasTransparency(src, 255); } + /** + * Checks if the image has transparency below a threshold. + * + * @param src the source image. + * @param threshold the alpha threshold (0-255). + * @return true if any pixel has alpha below threshold, false otherwise. + */ public boolean hasTransparency(final BufferedImage src, final int threshold) { final int width = src.getWidth(); final int height = src.getHeight(); @@ -296,6 +328,12 @@ public class PaletteFactory { return false; } + /** + * Checks if the image is grayscale. + * + * @param src the source image. + * @return true if the image is grayscale, false otherwise. + */ public boolean isGrayscale(final BufferedImage src) { final int width = src.getWidth(); final int height = src.getHeight();
