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 60416c5997cd429a2e5401c7674464defb4b709f Author: Gary Gregory <[email protected]> AuthorDate: Fri Jan 2 21:49:21 2026 -0500 Javadoc --- .../commons/imaging/color/ColorDin99Lab.java | 10 ++ .../org/apache/commons/imaging/color/ColorHsl.java | 12 ++ .../org/apache/commons/imaging/color/ColorHsv.java | 12 ++ .../commons/imaging/color/ColorHunterLab.java | 12 ++ .../org/apache/commons/imaging/color/ColorXyz.java | 12 ++ .../commons/imaging/common/BinaryFileParser.java | 30 ++++ .../commons/imaging/common/BinaryFunctions.java | 176 ++++++++++++++++++++- .../imaging/common/BufferedImageFactory.java | 20 +++ .../commons/imaging/common/ByteConversions.java | 171 +++++++++++++++++++- .../imaging/formats/bmp/BmpImagingParameters.java | 8 +- .../imaging/formats/dcx/DcxImageParser.java | 3 + .../formats/jpeg/segments/App13Segment.java | 14 +- .../imaging/formats/jpeg/segments/ComSegment.java | 18 +++ .../imaging/formats/jpeg/segments/DhtSegment.java | 51 ++++++ .../formats/psd/dataparsers/DataParserBitmap.java | 10 ++ .../formats/psd/dataparsers/DataParserCmyk.java | 11 ++ .../psd/dataparsers/DataParserGrayscale.java | 11 ++ .../formats/psd/dataparsers/DataParserIndexed.java | 8 + .../formats/psd/dataparsers/DataParserLab.java | 10 ++ .../formats/psd/dataparsers/DataParserRgb.java | 11 ++ .../formats/psd/dataparsers/DataParserStub.java | 11 ++ .../psd/datareaders/CompressedDataReader.java | 8 + .../formats/psd/datareaders/DataReader.java | 13 ++ .../formats/tiff/constants/DcfTagConstants.java | 11 ++ .../formats/tiff/constants/DngTagConstants.java | 42 +++++ .../formats/tiff/datareaders/DataReaderStrips.java | 18 +++ .../formats/tiff/datareaders/DataReaderTiled.java | 19 +++ .../org/apache/commons/imaging/internal/Debug.java | 8 + .../imaging/mylzw/BitsToByteInputStream.java | 24 +++ 29 files changed, 753 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/color/ColorDin99Lab.java b/src/main/java/org/apache/commons/imaging/color/ColorDin99Lab.java index af34d290..b4e5a3be 100644 --- a/src/main/java/org/apache/commons/imaging/color/ColorDin99Lab.java +++ b/src/main/java/org/apache/commons/imaging/color/ColorDin99Lab.java @@ -26,12 +26,22 @@ package org.apache.commons.imaging.color; */ public final class ColorDin99Lab { + /** The lightness component. */ public final double l99; + /** The a color component. */ public final double a99; + /** The b color component. */ public final double b99; + /** + * Constructs a new ColorDin99Lab. + * + * @param l99 the lightness component. + * @param a99 the a color component. + * @param b99 the b color component. + */ public ColorDin99Lab(final double l99, final double a99, final double b99) { this.l99 = l99; this.a99 = a99; diff --git a/src/main/java/org/apache/commons/imaging/color/ColorHsl.java b/src/main/java/org/apache/commons/imaging/color/ColorHsl.java index bccbda53..d6d7f23b 100644 --- a/src/main/java/org/apache/commons/imaging/color/ColorHsl.java +++ b/src/main/java/org/apache/commons/imaging/color/ColorHsl.java @@ -83,10 +83,22 @@ public final class ColorHsl { */ public static final ColorHsl BLUE = new ColorHsl(240, 100, 100); + /** The hue component (0-360). */ public final double h; + + /** The saturation component (0-100). */ public final double s; + + /** The lightness component (0-100). */ public final double l; + /** + * Constructs a new ColorHsl. + * + * @param h the hue component (0-360). + * @param s the saturation component (0-100). + * @param l the lightness component (0-100). + */ public ColorHsl(final double h, final double s, final double l) { this.h = h; this.s = s; diff --git a/src/main/java/org/apache/commons/imaging/color/ColorHsv.java b/src/main/java/org/apache/commons/imaging/color/ColorHsv.java index b00b7408..8e9e84b7 100644 --- a/src/main/java/org/apache/commons/imaging/color/ColorHsv.java +++ b/src/main/java/org/apache/commons/imaging/color/ColorHsv.java @@ -83,10 +83,22 @@ public final class ColorHsv { */ public static final ColorHsv BLUE = new ColorHsv(240, 100, 100); + /** The hue component (0-360). */ public final double h; + + /** The saturation component (0-100). */ public final double s; + + /** The value component (0-100). */ public final double v; + /** + * Constructs a new ColorHsv. + * + * @param h the hue component (0-360). + * @param s the saturation component (0-100). + * @param v the value component (0-100). + */ public ColorHsv(final double h, final double s, final double v) { this.h = h; this.s = s; diff --git a/src/main/java/org/apache/commons/imaging/color/ColorHunterLab.java b/src/main/java/org/apache/commons/imaging/color/ColorHunterLab.java index 5559fc57..8231655c 100644 --- a/src/main/java/org/apache/commons/imaging/color/ColorHunterLab.java +++ b/src/main/java/org/apache/commons/imaging/color/ColorHunterLab.java @@ -83,10 +83,22 @@ public final class ColorHunterLab { */ public static final ColorHunterLab BLUE = new ColorHunterLab(26.870, 72.885, -190.923); + /** The lightness component. */ public final double l; + + /** The a color component. */ public final double a; + + /** The b color component. */ public final double b; + /** + * Constructs a new ColorHunterLab. + * + * @param l the lightness component. + * @param a the a color component. + * @param b the b color component. + */ public ColorHunterLab(final double l, final double a, final double b) { this.l = l; this.a = a; diff --git a/src/main/java/org/apache/commons/imaging/color/ColorXyz.java b/src/main/java/org/apache/commons/imaging/color/ColorXyz.java index 09d377f3..7be3c614 100644 --- a/src/main/java/org/apache/commons/imaging/color/ColorXyz.java +++ b/src/main/java/org/apache/commons/imaging/color/ColorXyz.java @@ -83,10 +83,22 @@ public final class ColorXyz { */ public static final ColorXyz BLUE = new ColorXyz(18.05, 7.22, 95.05); + /** The X tristimulus value. */ public final double x; + + /** The Y tristimulus value. */ public final double y; + + /** The Z tristimulus value. */ public final double z; + /** + * Constructs a new ColorXyz. + * + * @param x the X tristimulus value. + * @param y the Y tristimulus value. + * @param z the Z tristimulus value. + */ public ColorXyz(final double x, final double y, final double z) { this.x = x; this.y = y; diff --git a/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java b/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java index 8a3e4fe4..dcbd05df 100644 --- a/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java +++ b/src/main/java/org/apache/commons/imaging/common/BinaryFileParser.java @@ -42,10 +42,23 @@ public class BinaryFileParser { // empty } + /** + * Constructs a new instance with the specified byte order. + * + * @param byteOrder the byte order to use. + */ public BinaryFileParser(final ByteOrder byteOrder) { this.byteOrder = byteOrder; } + /** + * Debugs a number by printing its representation to a PrintWriter. + * + * @param pw the PrintWriter. + * @param msg the message prefix. + * @param data the data value. + * @param bytes the number of bytes. + */ protected final void debugNumber(final PrintWriter pw, final String msg, final int data, final int bytes) { pw.print(msg + ": " + data + " ("); int byteData = data; @@ -61,6 +74,13 @@ public class BinaryFileParser { pw.flush(); } + /** + * Debugs a number by logging its representation. + * + * @param msg the message prefix. + * @param data the data value. + * @param bytes the number of bytes. + */ protected final void debugNumber(final String msg, final int data, final int bytes) { try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) { @@ -73,10 +93,20 @@ public class BinaryFileParser { } } + /** + * Gets the byte order used by this parser. + * + * @return the byte order. + */ public ByteOrder getByteOrder() { return byteOrder; } + /** + * Sets the byte order used by this parser. + * + * @param byteOrder the byte order to set. + */ protected void setByteOrder(final ByteOrder byteOrder) { this.byteOrder = byteOrder; } diff --git a/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java b/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java index 8c528811..1c3273fa 100644 --- a/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java +++ b/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java @@ -37,10 +37,29 @@ public final class BinaryFunctions { private static final byte NUL = (byte) 0; private static final Logger LOGGER = Logger.getLogger(BinaryFunctions.class.getName()); + /** + * Converts four characters to a 32-bit integer (quad). + * + * @param c1 the first character. + * @param c2 the second character. + * @param c3 the third character. + * @param c4 the fourth character. + * @return the 32-bit integer value. + */ public static int charsToQuad(final char c1, final char c2, final char c3, final char c4) { return (0xff & c1) << 24 | (0xff & c2) << 16 | (0xff & c3) << 8 | (0xff & c4) << 0; } + /** + * Compares byte arrays for equality within specified ranges. + * + * @param a the first byte array. + * @param aStart the starting index in the first array. + * @param b the second byte array. + * @param bStart the starting index in the second array. + * @param length the number of bytes to compare. + * @return {@code true} if the ranges are equal, {@code false} otherwise. + */ public static boolean compareBytes(final byte[] a, final int aStart, final byte[] b, final int bStart, final int length) { if (a.length < aStart + length) { return false; @@ -82,6 +101,16 @@ public final class BinaryFunctions { return copyOfRange(original, 0, count); } + /** + * Reads bytes from a RandomAccessFile at a specified position. + * + * @param raf the RandomAccessFile to read from. + * @param pos the position to start reading. + * @param length the number of bytes to read. + * @param exception the exception message if length is invalid. + * @return the bytes read. + * @throws IOException if an I/O error occurs or length is invalid. + */ public static byte[] getBytes(final RandomAccessFile raf, final long pos, final int length, final String exception) throws IOException { if (length < 0) { throw new IOException(String.format("%s, invalid length: %d", exception, length)); @@ -120,15 +149,34 @@ public final class BinaryFunctions { return indexOf0(src, 0, message); } + /** + * Logs the binary representation of a byte. + * + * @param msg the message prefix. + * @param i the byte value. + */ public static void logByteBits(final String msg, final byte i) { LOGGER.finest(msg + ": '" + Integer.toBinaryString(0xff & i)); } + /** + * Logs a quad as a character string. + * + * @param msg the message prefix. + * @param i the quad value. + */ public static void logCharQuad(final String msg, final int i) { LOGGER.finest(msg + ": '" + (char) (0xff & i >> 24) + (char) (0xff & i >> 16) + (char) (0xff & i >> 8) + (char) (0xff & i >> 0) + "'"); } + /** + * Prints a quad as a character string to a PrintWriter. + * + * @param pw the PrintWriter. + * @param msg the message prefix. + * @param i the quad value. + */ public static void printCharQuad(final PrintWriter pw, final String msg, final int i) { pw.println(msg + ": '" + (char) (0xff & i >> 24) + (char) (0xff & i >> 16) + (char) (0xff & i >> 8) + (char) (0xff & i >> 0) + "'"); } @@ -136,8 +184,8 @@ public final class BinaryFunctions { /** * Convert a quad into a byte array. * - * @param quad quad - * @return a byte array + * @param quad quad. + * @return a byte array. */ public static byte[] quadsToByteArray(final int quad) { final byte[] arr = new byte[4]; @@ -148,6 +196,16 @@ public final class BinaryFunctions { return arr; } + /** + * Reads 2 bytes from an input stream in the specified byte order. + * + * @param name the field name (for debugging). + * @param in the input stream. + * @param exception the exception message if read fails. + * @param byteOrder the byte order. + * @return the 16-bit value. + * @throws IOException if an I/O error occurs. + */ public static int read2Bytes(final String name, final InputStream in, final String exception, final ByteOrder byteOrder) throws IOException { final int byte0 = in.read(); final int byte1 = in.read(); @@ -163,6 +221,16 @@ public final class BinaryFunctions { return result; } + /** + * Reads 3 bytes from an input stream in the specified byte order. + * + * @param name the field name (for debugging). + * @param in the input stream. + * @param exception the exception message if read fails. + * @param byteOrder the byte order. + * @return the 24-bit value. + * @throws IOException if an I/O error occurs. + */ public static int read3Bytes(final String name, final InputStream in, final String exception, final ByteOrder byteOrder) throws IOException { final int byte0 = in.read(); final int byte1 = in.read(); @@ -179,6 +247,16 @@ public final class BinaryFunctions { return result; } + /** + * Reads 4 bytes from an input stream in the specified byte order. + * + * @param name the field name (for debugging). + * @param in the input stream. + * @param exception the exception message if read fails. + * @param byteOrder the byte order. + * @return the 32-bit value. + * @throws IOException if an I/O error occurs. + */ public static int read4Bytes(final String name, final InputStream in, final String exception, final ByteOrder byteOrder) throws IOException { final int byte0 = in.read(); final int byte1 = in.read(); @@ -227,10 +305,28 @@ public final class BinaryFunctions { return result; } + /** + * Reads and verifies bytes match a BinaryConstant. + * + * @param in the input stream. + * @param expected the expected binary constant. + * @param exception the exception message if bytes don't match. + * @throws ImagingException if the bytes don't match or EOF is reached. + * @throws IOException if an I/O error occurs. + */ public static void readAndVerifyBytes(final InputStream in, final BinaryConstant expected, final String exception) throws ImagingException, IOException { readAndVerifyBytes(in, expected.rawValue(), exception); } + /** + * Reads and verifies bytes match an expected byte array. + * + * @param in the input stream. + * @param expected the expected byte array. + * @param exception the exception message if bytes don't match. + * @throws ImagingException if the bytes don't match or EOF is reached. + * @throws IOException if an I/O error occurs. + */ public static void readAndVerifyBytes(final InputStream in, final byte[] expected, final String exception) throws ImagingException, IOException { for (final byte element : expected) { final int data = in.read(); @@ -244,6 +340,15 @@ public final class BinaryFunctions { } } + /** + * Reads a single byte from an input stream. + * + * @param name the field name (for debugging). + * @param in the input stream. + * @param exceptionMessage the exception message if read fails. + * @return the byte read. + * @throws IOException if an I/O error occurs. + */ public static byte readByte(final String name, final InputStream in, final String exceptionMessage) throws IOException { final int result = in.read(); if (result < 0) { @@ -252,14 +357,41 @@ public final class BinaryFunctions { return (byte) (0xff & result); } + /** + * Reads a specified number of bytes from an input stream. + * + * @param in the input stream. + * @param count the number of bytes to read. + * @return the bytes read. + * @throws IOException if an I/O error occurs. + */ public static byte[] readBytes(final InputStream in, final int count) throws IOException { return readBytes("", in, count, "Unexpected EOF"); } + /** + * Reads a specified number of bytes from an input stream. + * + * @param name the field name (for debugging). + * @param in the input stream. + * @param length the number of bytes to read. + * @return the bytes read. + * @throws IOException if an I/O error occurs. + */ public static byte[] readBytes(final String name, final InputStream in, final int length) throws IOException { return readBytes(name, in, length, name + " could not be read."); } + /** + * Reads a specified number of bytes from an input stream with a custom exception message. + * + * @param name the field name (for debugging). + * @param in the input stream. + * @param length the number of bytes to read. + * @param exception the exception message if read fails. + * @return the bytes read. + * @throws IOException if an I/O error occurs. + */ public static byte[] readBytes(final String name, final InputStream in, final int length, final String exception) throws IOException { try { return in == null ? ArrayUtils.EMPTY_BYTE_ARRAY : IOUtils.toByteArray(in, Allocator.check(length)); @@ -268,6 +400,14 @@ public final class BinaryFunctions { } } + /** + * Gets the remaining bytes from a byte array starting at a specified offset. + * + * @param name the field name (for debugging). + * @param bytes the source byte array. + * @param count the starting offset. + * @return the remaining bytes. + */ public static byte[] remainingBytes(final String name, final byte[] bytes, final int count) { return copyOfRange(bytes, count, bytes.length - count); } @@ -279,10 +419,10 @@ public final class BinaryFunctions { * <p> * Returns {@code true} if it found the quad, and {@code false} otherwise. * - * @param quad a quad (the needle) - * @param in an input stream (the haystack) - * @return {@code true} if it found the quad, and {@code false} otherwise - * @throws IOException if it fails to read from the given input stream + * @param quad a quad (the needle). + * @param in an input stream (the haystack). + * @return {@code true} if it found the quad, and {@code false} otherwise. + * @throws IOException if it fails to read from the given input stream. */ public static boolean searchQuad(final int quad, final InputStream in) throws IOException { final byte[] needle = quadsToByteArray(quad); @@ -301,10 +441,27 @@ public final class BinaryFunctions { return false; } + /** + * Skips a specified number of bytes in an input stream. + * + * @param in the input stream. + * @param skip the number of bytes to skip. + * @return the number of bytes actually skipped. + * @throws IOException if an I/O error occurs. + */ public static long skipBytes(final InputStream in, final long skip) throws IOException { return skipBytes(in, skip, "Couldn't skip bytes"); } + /** + * Skips a specified number of bytes in an input stream with a custom exception message. + * + * @param in the input stream. + * @param skip the number of bytes to skip. + * @param exMessage the exception message if skip fails. + * @return the number of bytes actually skipped. + * @throws IOException if an I/O error occurs. + */ public static long skipBytes(final InputStream in, final long skip, final String exMessage) throws IOException { try { return IOUtils.skip(in, skip); @@ -313,6 +470,13 @@ public final class BinaryFunctions { } } + /** + * Tests whether a byte array starts with a specified byte sequence. + * + * @param buffer the buffer to test. + * @param search the byte sequence to search for. + * @return {@code true} if the buffer starts with the search sequence, {@code false} otherwise. + */ public static boolean startsWith(final byte[] buffer, final byte[] search) { if (search == null) { return false; diff --git a/src/main/java/org/apache/commons/imaging/common/BufferedImageFactory.java b/src/main/java/org/apache/commons/imaging/common/BufferedImageFactory.java index 43ea6302..d693e3fe 100644 --- a/src/main/java/org/apache/commons/imaging/common/BufferedImageFactory.java +++ b/src/main/java/org/apache/commons/imaging/common/BufferedImageFactory.java @@ -19,8 +19,28 @@ package org.apache.commons.imaging.common; import java.awt.image.BufferedImage; +/** + * Creates BufferedImage instances. + */ public interface BufferedImageFactory { + + /** + * Creates a color BufferedImage with the specified dimensions. + * + * @param width the image width. + * @param height the image height. + * @param hasAlpha whether the image has an alpha channel. + * @return a new BufferedImage. + */ BufferedImage getColorBufferedImage(int width, int height, boolean hasAlpha); + /** + * Creates a grayscale BufferedImage with the specified dimensions. + * + * @param width the image width. + * @param height the image height. + * @param hasAlpha whether the image has an alpha channel. + * @return a new BufferedImage. + */ BufferedImage getGrayscaleBufferedImage(int width, int height, boolean hasAlpha); } diff --git a/src/main/java/org/apache/commons/imaging/common/ByteConversions.java b/src/main/java/org/apache/commons/imaging/common/ByteConversions.java index 05d9cdf4..be03973e 100644 --- a/src/main/java/org/apache/commons/imaging/common/ByteConversions.java +++ b/src/main/java/org/apache/commons/imaging/common/ByteConversions.java @@ -23,6 +23,14 @@ import java.util.Arrays; * Convenience methods for converting data types to and from byte arrays. */ public final class ByteConversions { + + /** + * Converts a double value to a byte array in the specified byte order. + * + * @param value the double value. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final double value, final ByteOrder byteOrder) { final byte[] result = new byte[8]; toBytes(value, byteOrder, result, 0); @@ -52,6 +60,13 @@ public final class ByteConversions { } } + /** + * Converts a double array to a byte array in the specified byte order. + * + * @param values the double array. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final double[] values, final ByteOrder byteOrder) { return toBytes(values, 0, values.length, byteOrder); } @@ -64,6 +79,13 @@ public final class ByteConversions { return result; } + /** + * Converts a float value to a byte array in the specified byte order. + * + * @param value the float value. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final float value, final ByteOrder byteOrder) { final byte[] result = new byte[4]; toBytes(value, byteOrder, result, 0); @@ -85,6 +107,13 @@ public final class ByteConversions { } } + /** + * Converts a float array to a byte array in the specified byte order. + * + * @param values the float array. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final float[] values, final ByteOrder byteOrder) { return toBytes(values, 0, values.length, byteOrder); } @@ -97,6 +126,13 @@ public final class ByteConversions { return result; } + /** + * Converts an int value to a byte array in the specified byte order. + * + * @param value the int value. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final int value, final ByteOrder byteOrder) { final byte[] result = new byte[4]; toBytes(value, byteOrder, result, 0); @@ -117,6 +153,13 @@ public final class ByteConversions { } } + /** + * Converts an int array to a byte array in the specified byte order. + * + * @param values the int array. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final int[] values, final ByteOrder byteOrder) { return toBytes(values, 0, values.length, byteOrder); } @@ -132,9 +175,9 @@ public final class ByteConversions { /** * Encodes an eight-byte (long) into an array of bytes based on the specified byte order. * - * @param value a standard data primitive of type long - * @param byteOrder the byte order to be used for encoding - * @return an array of length 8 + * @param value a standard data primitive of type long. + * @param byteOrder the byte order to be used for encoding. + * @return an array of length 8. */ public static byte[] toBytes(final long value, final ByteOrder byteOrder) { final byte[] result = new byte[8]; @@ -164,6 +207,13 @@ public final class ByteConversions { } } + /** + * Converts a RationalNumber to a byte array in the specified byte order. + * + * @param value the RationalNumber. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final RationalNumber value, final ByteOrder byteOrder) { final byte[] result = new byte[8]; toBytes(value, byteOrder, result, 0); @@ -192,6 +242,13 @@ public final class ByteConversions { } } + /** + * Converts a RationalNumber array to a byte array in the specified byte order. + * + * @param values the RationalNumber array. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final RationalNumber[] values, final ByteOrder byteOrder) { return toBytes(values, 0, values.length, byteOrder); } @@ -204,6 +261,13 @@ public final class ByteConversions { return result; } + /** + * Converts a short value to a byte array in the specified byte order. + * + * @param value the short value. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final short value, final ByteOrder byteOrder) { final byte[] result = new byte[2]; toBytes(value, byteOrder, result, 0); @@ -220,6 +284,13 @@ public final class ByteConversions { } } + /** + * Converts a short array to a byte array in the specified byte order. + * + * @param values the short array. + * @param byteOrder the byte order. + * @return the byte array. + */ public static byte[] toBytes(final short[] values, final ByteOrder byteOrder) { return toBytes(values, 0, values.length, byteOrder); } @@ -232,6 +303,13 @@ public final class ByteConversions { return result; } + /** + * Converts a byte array to a double in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the double value. + */ public static double toDouble(final byte[] bytes, final ByteOrder byteOrder) { return toDouble(bytes, 0, byteOrder); } @@ -254,6 +332,13 @@ public final class ByteConversions { return Double.longBitsToDouble(bits); } + /** + * Converts a byte array to a double array in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the double array. + */ public static double[] toDoubles(final byte[] bytes, final ByteOrder byteOrder) { return toDoubles(bytes, 0, bytes.length, byteOrder); } @@ -264,6 +349,13 @@ public final class ByteConversions { return result; } + /** + * Converts a byte array to a float in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the float value. + */ public static float toFloat(final byte[] bytes, final ByteOrder byteOrder) { return toFloat(bytes, 0, byteOrder); } @@ -282,6 +374,13 @@ public final class ByteConversions { return Float.intBitsToFloat(bits); } + /** + * Converts a byte array to a float array in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the float array. + */ public static float[] toFloats(final byte[] bytes, final ByteOrder byteOrder) { return toFloats(bytes, 0, bytes.length, byteOrder); } @@ -294,10 +393,25 @@ public final class ByteConversions { return result; } + /** + * Converts a byte array to an int in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the int value. + */ public static int toInt(final byte[] bytes, final ByteOrder byteOrder) { return toInt(bytes, 0, byteOrder); } + /** + * Converts a byte array to an int in the specified byte order starting at an offset. + * + * @param bytes the byte array. + * @param offset the starting offset. + * @param byteOrder the byte order. + * @return the int value. + */ public static int toInt(final byte[] bytes, final int offset, final ByteOrder byteOrder) { final int byte0 = 0xff & bytes[offset + 0]; final int byte1 = 0xff & bytes[offset + 1]; @@ -309,6 +423,13 @@ public final class ByteConversions { return byte3 << 24 | byte2 << 16 | byte1 << 8 | byte0; } + /** + * Converts a byte array to an int array in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the int array. + */ public static int[] toInts(final byte[] bytes, final ByteOrder byteOrder) { return toInts(bytes, 0, bytes.length, byteOrder); } @@ -398,6 +519,14 @@ public final class ByteConversions { return new RationalNumber(numerator, divisor, unsignedType); } + /** + * Converts a byte array to a RationalNumber array in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @param unsignedType indicates whether the extracted value is an unsigned type. + * @return the RationalNumber array. + */ public static RationalNumber[] toRationals(final byte[] bytes, final ByteOrder byteOrder, final boolean unsignedType) { return toRationals(bytes, 0, bytes.length, byteOrder, unsignedType); } @@ -408,6 +537,13 @@ public final class ByteConversions { return result; } + /** + * Converts a byte array to a short in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the short value. + */ public static short toShort(final byte[] bytes, final ByteOrder byteOrder) { return toShort(bytes, 0, byteOrder); } @@ -416,6 +552,13 @@ public final class ByteConversions { return (short) toUInt16(bytes, offset, byteOrder); } + /** + * Converts a byte array to a short array in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the short array. + */ public static short[] toShorts(final byte[] bytes, final ByteOrder byteOrder) { return toShorts(bytes, 0, bytes.length, byteOrder); } @@ -428,10 +571,25 @@ public final class ByteConversions { return result; } + /** + * Converts a byte array to an unsigned 16-bit integer in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the unsigned 16-bit integer value. + */ public static int toUInt16(final byte[] bytes, final ByteOrder byteOrder) { return toUInt16(bytes, 0, byteOrder); } + /** + * Converts a byte array to an unsigned 16-bit integer in the specified byte order starting at an offset. + * + * @param bytes the byte array. + * @param offset the starting offset. + * @param byteOrder the byte order. + * @return the unsigned 16-bit integer value. + */ public static int toUInt16(final byte[] bytes, final int offset, final ByteOrder byteOrder) { final int byte0 = 0xff & bytes[offset + 0]; final int byte1 = 0xff & bytes[offset + 1]; @@ -441,6 +599,13 @@ public final class ByteConversions { return byte1 << 8 | byte0; } + /** + * Converts a byte array to an array of unsigned 16-bit integers in the specified byte order. + * + * @param bytes the byte array. + * @param byteOrder the byte order. + * @return the array of unsigned 16-bit integers. + */ public static int[] toUInt16s(final byte[] bytes, final ByteOrder byteOrder) { return toUInt16s(bytes, 0, bytes.length, byteOrder); } diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImagingParameters.java b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImagingParameters.java index eeb7891d..84b9c11f 100644 --- a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImagingParameters.java +++ b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImagingParameters.java @@ -25,5 +25,11 @@ import org.apache.commons.imaging.ImagingParameters; * @since 1.0-alpha3 */ public class BmpImagingParameters extends ImagingParameters<BmpImagingParameters> { - // empty + + /** + * Constructs a new BmpImagingParameters. + */ + public BmpImagingParameters() { + // Default constructor + } } diff --git a/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java b/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java index bcd11e0e..5070c4f6 100644 --- a/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java @@ -40,6 +40,9 @@ import org.apache.commons.imaging.common.ImageMetadata; import org.apache.commons.imaging.formats.pcx.PcxImageParser; import org.apache.commons.imaging.formats.pcx.PcxImagingParameters; +/** + * Parser for DCX (multi-page PCX) image format. + */ public class DcxImageParser extends AbstractImageParser<PcxImagingParameters> { private static final class DcxHeader { diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App13Segment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App13Segment.java index fefcf730..4f177a8d 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App13Segment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App13Segment.java @@ -53,7 +53,19 @@ public class App13Segment extends AppnSegment { public App13Segment(final int marker, final int markerLength, final InputStream is) throws IOException { super(marker, markerLength, is); - // ...existing code... + // isIPTCJpegSegment = new IptcParser().isIPTCJpegSegment(bytes); + // if (isIPTCJpegSegment) + // { + // /* + // * In practice, App13 segments are only used for Photoshop/IPTC + // * metadata. However, we should not treat App13 signatures without + // * Photoshop's signature as Photoshop/IPTC segments. + // */ + // boolean verbose = false; + // boolean strict = false; + // elements.addAll(new IptcParser().parseIPTCJPEGSegment(bytes, + // verbose, strict)); + // } } /** diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java index f3b1308e..61e3e2aa 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java @@ -20,11 +20,29 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +/** + * A JPEG COM (comment) segment. + */ public class ComSegment extends AbstractGenericSegment { + + /** + * Constructs a COM segment from segment data. + * + * @param marker the segment marker. + * @param segmentData the segment data. + */ public ComSegment(final int marker, final byte[] segmentData) { super(marker, segmentData); } + /** + * Constructs a COM segment by reading from an input stream. + * + * @param marker the segment marker. + * @param markerLength the marker length. + * @param is the input stream to read from. + * @throws IOException if an I/O error occurs. + */ public ComSegment(final int marker, final int markerLength, final InputStream is) throws IOException { super(marker, markerLength, is); } diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java index 350e417f..a8b602d0 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java @@ -26,13 +26,24 @@ import java.util.List; import org.apache.commons.imaging.common.Allocator; +/** + * A JPEG DHT (Define Huffman Table) segment. + */ public final class DhtSegment extends AbstractSegment { + /** + * Represents a Huffman table for JPEG decoding. + */ public static class HuffmanTable { // some arrays are better off one-based // to avoid subtractions by one later when indexing them + + /** The table class (0=DC, 1=AC). */ public final int tableClass; + + /** The destination identifier. */ public final int destinationIdentifier; + private final int[] huffVal; // 0-based // derived properties: @@ -117,29 +128,69 @@ public final class DhtSegment extends AbstractSegment { } + /** + * Gets the Huffman value at the specified index. + * + * @param i the index. + * @return the Huffman value. + */ public int getHuffVal(final int i) { return huffVal[i]; } + /** + * Gets the maximum code for the specified bit length. + * + * @param i the bit length. + * @return the maximum code. + */ public int getMaxCode(final int i) { return maxCode[i]; } + /** + * Gets the minimum code for the specified bit length. + * + * @param i the bit length. + * @return the minimum code. + */ public int getMinCode(final int i) { return minCode[i]; } + /** + * Gets the value pointer for the specified bit length. + * + * @param i the bit length. + * @return the value pointer. + */ public int getValPtr(final int i) { return valPtr[i]; } } + /** The list of Huffman tables in this segment. */ public final List<HuffmanTable> huffmanTables; + /** + * Constructs a DHT segment from segment data. + * + * @param marker the segment marker. + * @param segmentData the segment data. + * @throws IOException if an I/O error occurs. + */ public DhtSegment(final int marker, final byte[] segmentData) throws IOException { this(marker, segmentData.length, new ByteArrayInputStream(segmentData)); } + /** + * Constructs a DHT segment by reading from an input stream. + * + * @param marker the segment marker. + * @param length the segment length. + * @param is the input stream to read from. + * @throws IOException if an I/O error occurs. + */ public DhtSegment(final int marker, int length, final InputStream is) throws IOException { super(marker, length); diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java index a731f7e8..d52431c1 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserBitmap.java @@ -18,8 +18,18 @@ package org.apache.commons.imaging.formats.psd.dataparsers; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Parser for bitmap mode PSD image data. + */ public class DataParserBitmap extends AbstractDataParser { + /** + * Constructs a new bitmap data parser. + */ + public DataParserBitmap() { + super(); + } + @Override public int getBasicChannelsCount() { return 1; diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java index 01ced386..5a30a269 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserCmyk.java @@ -19,7 +19,18 @@ package org.apache.commons.imaging.formats.psd.dataparsers; import org.apache.commons.imaging.color.ColorConversions; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Parser for CMYK mode PSD image data. + */ public class DataParserCmyk extends AbstractDataParser { + + /** + * Constructs a new CMYK data parser. + */ + public DataParserCmyk() { + super(); + } + @Override public int getBasicChannelsCount() { return 4; diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java index 845e3d78..15b8b973 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserGrayscale.java @@ -18,7 +18,18 @@ package org.apache.commons.imaging.formats.psd.dataparsers; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Parser for grayscale mode PSD image data. + */ public class DataParserGrayscale extends AbstractDataParser { + + /** + * Constructs a new grayscale data parser. + */ + public DataParserGrayscale() { + super(); + } + @Override public int getBasicChannelsCount() { return 1; diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java index df9dd4b2..5037ae40 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserIndexed.java @@ -20,9 +20,17 @@ import java.util.Arrays; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Parser for indexed color mode PSD image data. + */ public class DataParserIndexed extends AbstractDataParser { private final int[] colorTable; + /** + * Constructs a new indexed color data parser. + * + * @param colorModeData the color mode data containing the color table. + */ public DataParserIndexed(final byte[] colorModeData) { colorTable = new int[256]; Arrays.setAll(colorTable, i -> { diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLab.java b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLab.java index f97a7bb3..eed9b6d6 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLab.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserLab.java @@ -19,8 +19,18 @@ package org.apache.commons.imaging.formats.psd.dataparsers; import org.apache.commons.imaging.color.ColorConversions; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Parser for Lab color mode PSD image data. + */ public class DataParserLab extends AbstractDataParser { + /** + * Constructs a new Lab data parser. + */ + public DataParserLab() { + super(); + } + @Override public int getBasicChannelsCount() { return 3; diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserRgb.java b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserRgb.java index 39368772..7788d5c9 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserRgb.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserRgb.java @@ -18,7 +18,18 @@ package org.apache.commons.imaging.formats.psd.dataparsers; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Parser for RGB color mode PSD image data. + */ public class DataParserRgb extends AbstractDataParser { + + /** + * Constructs a new RGB data parser. + */ + public DataParserRgb() { + super(); + } + @Override public int getBasicChannelsCount() { return 3; diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserStub.java b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserStub.java index 834817da..d4a9df98 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserStub.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/dataparsers/DataParserStub.java @@ -18,7 +18,18 @@ package org.apache.commons.imaging.formats.psd.dataparsers; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Stub parser for unsupported PSD color modes. + */ public class DataParserStub extends AbstractDataParser { + + /** + * Constructs a new stub data parser. + */ + public DataParserStub() { + super(); + } + @Override public int getBasicChannelsCount() { return 1; diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java b/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java index 0c4682d9..dce193a1 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/CompressedDataReader.java @@ -33,10 +33,18 @@ import org.apache.commons.imaging.formats.psd.dataparsers.AbstractDataParser; import org.apache.commons.imaging.mylzw.BitsToByteInputStream; import org.apache.commons.imaging.mylzw.MyBitInputStream; +/** + * Reader for compressed PSD image data. + */ public class CompressedDataReader implements DataReader { private final AbstractDataParser dataParser; + /** + * Constructs a new compressed data reader. + * + * @param dataParser the data parser to use. + */ public CompressedDataReader(final AbstractDataParser dataParser) { this.dataParser = dataParser; } diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/DataReader.java b/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/DataReader.java index 3700f0c1..3ef28504 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/DataReader.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/datareaders/DataReader.java @@ -24,8 +24,21 @@ import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.BinaryFileParser; import org.apache.commons.imaging.formats.psd.PsdImageContents; +/** + * Reads PSD image data. + */ public interface DataReader { + /** + * Reads image data from an input stream into a BufferedImage. + * + * @param is the input stream. + * @param bi the BufferedImage to populate. + * @param imageContents the PSD image contents. + * @param bfp the binary file parser. + * @throws ImagingException if the image format is invalid. + * @throws IOException if an I/O error occurs. + */ void readData(InputStream is, BufferedImage bi, PsdImageContents imageContents, BinaryFileParser bfp) throws ImagingException, IOException; } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java index 06448620..0475919b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java @@ -33,20 +33,31 @@ import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrLong; */ public final class DcfTagConstants { + /** Related image file format tag. */ public static final TagInfoAscii EXIF_TAG_RELATED_IMAGE_FILE_FORMAT = new TagInfoAscii("RelatedImageFileFormat", 0x1000, -1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); + /** Related image width tag. */ public static final TagInfoShortOrLong EXIF_TAG_RELATED_IMAGE_WIDTH = new TagInfoShortOrLong("RelatedImageWidth", 0x1001, 1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); + /** Related image length tag. */ public static final TagInfoShortOrLong EXIF_TAG_RELATED_IMAGE_LENGTH = new TagInfoShortOrLong("RelatedImageLength", 0x1002, 1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); + /** Color space tag. */ public static final TagInfoShort EXIF_TAG_COLOR_SPACE = new TagInfoShort("ColorSpace", 0xa001, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); + + /** Color space value: sRGB. */ public static final int COLOR_SPACE_VALUE_SRGB = 1; + + /** Color space value: Adobe RGB. */ public static final int COLOR_SPACE_VALUE_ADOBE_RGB = 2; + + /** Color space value: uncalibrated. */ public static final int COLOR_SPACE_VALUE_UNCALIBRATED = 65535; + /** List of all DCF tags. */ public static final List<TagInfo> ALL_DCF_TAGS = Collections.unmodifiableList( Arrays.asList(EXIF_TAG_RELATED_IMAGE_FILE_FORMAT, EXIF_TAG_RELATED_IMAGE_WIDTH, EXIF_TAG_RELATED_IMAGE_LENGTH, EXIF_TAG_COLOR_SPACE)); diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java index fc0b7c8b..82a7a004 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java @@ -146,27 +146,68 @@ public final class DngTagConstants { public static final int MAKER_NOTE_SAFETY_VALUE_UNSAFE = 0; public static final int MAKER_NOTE_SAFETY_VALUE_SAFE = 1; + /** Calibration illuminant 1 tag. */ public static final TagInfoShort EXIF_TAG_CALIBRATION_ILLUMINANT_1 = new TagInfoShort("CalibrationIlluminant1", 0xc65a, TiffDirectoryType.EXIF_DIRECTORY_IFD0); + + /** Calibration illuminant 1 value: daylight. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_DAYLIGHT = 1; + + /** Calibration illuminant 1 value: fluorescent. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_FLUORESCENT = 2; + + /** Calibration illuminant 1 value: tungsten. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_TUNGSTEN = 3; + + /** Calibration illuminant 1 value: flash. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_FLASH = 4; + + /** Calibration illuminant 1 value: fine weather. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_FINE_WEATHER = 9; + + /** Calibration illuminant 1 value: cloudy. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_CLOUDY = 10; + + /** Calibration illuminant 1 value: shade. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_SHADE = 11; + + /** Calibration illuminant 1 value: daylight fluorescent. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_DAYLIGHT_FLUORESCENT = 12; + + /** Calibration illuminant 1 value: day white fluorescent. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_DAY_WHITE_FLUORESCENT = 13; + + /** Calibration illuminant 1 value: cool white fluorescent. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_COOL_WHITE_FLUORESCENT = 14; + + /** Calibration illuminant 1 value: white fluorescent. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_WHITE_FLUORESCENT = 15; + + /** Calibration illuminant 1 value: standard light A. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_STANDARD_LIGHT_A = 17; + + /** Calibration illuminant 1 value: standard light B. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_STANDARD_LIGHT_B = 18; + + /** Calibration illuminant 1 value: standard light C. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_STANDARD_LIGHT_C = 19; + + /** Calibration illuminant 1 value: D55. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_D55 = 20; + + /** Calibration illuminant 1 value: D65. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_D65 = 21; + + /** Calibration illuminant 1 value: D75. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_D75 = 22; + + /** Calibration illuminant 1 value: D50. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_D50 = 23; + + /** Calibration illuminant 1 value: ISO studio tungsten. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_ISO_STUDIO_TUNGSTEN = 24; + + /** Calibration illuminant 1 value: other. */ public static final int CALIBRATION_ILLUMINANT_1_VALUE_OTHER = 255; public static final TagInfoShort EXIF_TAG_CALIBRATION_ILLUMINANT_2 = new TagInfoShort("CalibrationIlluminant2", 0xc65b, @@ -277,6 +318,7 @@ public final class DngTagConstants { public static final TagInfoBytes EXIF_TAG_PREVIEW_SETTINGS_DIGEST = new TagInfoBytes("PreviewSettingsDigest", 0xc719, 16, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); + /** Preview colorspace tag. */ public static final TagInfoLong EXIF_TAG_PREVIEW_COLORSPACE = new TagInfoLong("PreviewColorspace", 0xc71a, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); public static final int PREVIEW_COLORSPACE_VALUE_UNKNOWN = 0; public static final int PREVIEW_COLORSPACE_VALUE_GRAY_GAMMA_2_2 = 1; diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java index bd8177e4..4464abe3 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java @@ -52,6 +52,24 @@ public final class DataReaderStrips extends AbstractImageDataReader { private int y; private final AbstractTiffImageData.Strips imageData; + /** + * Constructs a new data reader for strip-based TIFF images. + * + * @param directory the TIFF directory. + * @param photometricInterpreter the photometric interpreter. + * @param bitsPerPixel the bits per pixel. + * @param bitsPerSample the bits per sample array. + * @param predictor the predictor value. + * @param samplesPerPixel the samples per pixel. + * @param sampleFormat the sample format. + * @param width the image width. + * @param height the image height. + * @param compression the compression type. + * @param planarConfiguration the planar configuration. + * @param byteOrder the byte order. + * @param rowsPerStrip the rows per strip. + * @param imageData the strip image data. + */ public DataReaderStrips(final TiffDirectory directory, final AbstractPhotometricInterpreter photometricInterpreter, final int bitsPerPixel, final int[] bitsPerSample, final int predictor, final int samplesPerPixel, final int sampleFormat, final int width, final int height, final int compression, final TiffPlanarConfiguration planarConfiguration, final ByteOrder byteOrder, final int rowsPerStrip, diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java index d3614b64..6ccd682b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java @@ -57,6 +57,25 @@ public final class DataReaderTiled extends AbstractImageDataReader { private final AbstractTiffImageData.Tiles imageData; + /** + * Constructs a new data reader for tile-based TIFF images. + * + * @param directory the TIFF directory. + * @param photometricInterpreter the photometric interpreter. + * @param tileWidth the tile width. + * @param tileLength the tile length. + * @param bitsPerPixel the bits per pixel. + * @param bitsPerSample the bits per sample array. + * @param predictor the predictor value. + * @param samplesPerPixel the samples per pixel. + * @param sampleFormat the sample format. + * @param width the image width. + * @param height the image height. + * @param compression the compression type. + * @param planarConfiguration the planar configuration. + * @param byteOrder the byte order. + * @param imageData the tile image data. + */ public DataReaderTiled(final TiffDirectory directory, final AbstractPhotometricInterpreter photometricInterpreter, final int tileWidth, final int tileLength, final int bitsPerPixel, final int[] bitsPerSample, final int predictor, final int samplesPerPixel, final int sampleFormat, final int width, final int height, final int compression, final TiffPlanarConfiguration planarConfiguration, final ByteOrder byteOrder, diff --git a/src/main/java/org/apache/commons/imaging/internal/Debug.java b/src/main/java/org/apache/commons/imaging/internal/Debug.java index eba167ac..7e9f8740 100644 --- a/src/main/java/org/apache/commons/imaging/internal/Debug.java +++ b/src/main/java/org/apache/commons/imaging/internal/Debug.java @@ -69,12 +69,20 @@ public final class Debug { return buffer.toString(); } + /** + * Logs a debug message (newline only). + */ public static void debug() { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest(NEWLINE); } } + /** + * Logs a debug message. + * + * @param message the message to log. + */ public static void debug(final String message) { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest(message); diff --git a/src/main/java/org/apache/commons/imaging/mylzw/BitsToByteInputStream.java b/src/main/java/org/apache/commons/imaging/mylzw/BitsToByteInputStream.java index 4cc5674e..79db9e4e 100644 --- a/src/main/java/org/apache/commons/imaging/mylzw/BitsToByteInputStream.java +++ b/src/main/java/org/apache/commons/imaging/mylzw/BitsToByteInputStream.java @@ -21,9 +21,18 @@ import java.io.IOException; import org.apache.commons.imaging.common.Allocator; +/** + * Input stream that converts bit-based input to byte-based output with depth adjustment. + */ public class BitsToByteInputStream extends FilterInputStream { private final int desiredDepth; + /** + * Constructs a new BitsToByteInputStream. + * + * @param is the MyBitInputStream to read from. + * @param desiredDepth the desired bit depth. + */ public BitsToByteInputStream(final MyBitInputStream is, final int desiredDepth) { super(is); this.desiredDepth = desiredDepth; @@ -34,6 +43,13 @@ public class BitsToByteInputStream extends FilterInputStream { return readBits(8); } + /** + * Reads the specified number of bits and adjusts to the desired depth. + * + * @param bitCount the number of bits to read. + * @return the adjusted value. + * @throws IOException if an I/O error occurs. + */ public int readBits(final int bitCount) throws IOException { int i = ((MyBitInputStream) in).readBits(bitCount); if (bitCount < desiredDepth) { @@ -45,6 +61,14 @@ public class BitsToByteInputStream extends FilterInputStream { return i; } + /** + * Reads an array of bit values. + * + * @param sampleBits the number of bits per sample. + * @param length the number of samples to read. + * @return the array of values. + * @throws IOException if an I/O error occurs. + */ public int[] readBitsArray(final int sampleBits, final int length) throws IOException { final int[] result = Allocator.intArray(length); for (int i = 0; i < length; i++) {
