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 10714e207636d5947e9d305e546d9b962fc2f28f Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Nov 13 14:09:07 2023 -0500 Use Checkstyle WhitespaceAround --- src/conf/checkstyle.xml | 1 + .../commons/imaging/common/RationalNumber.java | 4 +- .../imaging/formats/gif/GifImageParser.java | 6 +- .../imaging/formats/jpeg/decoder/JpegDecoder.java | 2 +- .../imaging/formats/png/PngImagingParameters.java | 4 +- .../commons/imaging/formats/png/PngWriter.java | 3 +- .../commons/imaging/formats/tiff/TiffField.java | 33 +++---- .../imaging/formats/tiff/TiffRasterData.java | 10 +- .../tiff/datareaders/DataInterpreterJpeg.java | 2 +- .../formats/tiff/datareaders/DataReaderStrips.java | 4 +- .../formats/tiff/datareaders/ImageDataReader.java | 14 +-- .../formats/tiff/itu_t4/T4AndT6Compression.java | 29 +++--- .../tiff/write/AbstractTiffImageWriter.java | 102 +++++++-------------- .../imaging/internal/ImageParserFactory.java | 3 +- 14 files changed, 90 insertions(+), 127 deletions(-) diff --git a/src/conf/checkstyle.xml b/src/conf/checkstyle.xml index 44aa2940..d87695d4 100644 --- a/src/conf/checkstyle.xml +++ b/src/conf/checkstyle.xml @@ -62,6 +62,7 @@ limitations under the License. <property name="ordered" value="true"/> <property name="separated" value="true"/> </module> + <module name="WhitespaceAroundCheck"/> </module> <module name="LineLength"> <property name="max" value="160" /> diff --git a/src/main/java/org/apache/commons/imaging/common/RationalNumber.java b/src/main/java/org/apache/commons/imaging/common/RationalNumber.java index d16159f5..324952bd 100644 --- a/src/main/java/org/apache/commons/imaging/common/RationalNumber.java +++ b/src/main/java/org/apache/commons/imaging/common/RationalNumber.java @@ -221,9 +221,9 @@ public class RationalNumber extends Number { * @param unsignedType indicates how numerator and divisor values * are to be interpreted. */ - private RationalNumber(final long numerator, final long divisor, final boolean unsignedType){ + private RationalNumber(final long numerator, final long divisor, final boolean unsignedType) { this.numerator = numerator; - this.divisor = divisor; + this.divisor = divisor; this.unsignedType = unsignedType; } 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 02144176..94d999d7 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 @@ -176,7 +176,7 @@ public class GifImageParser extends AbstractImageParser<GifImagingParameters> im } final List<GifImageData> imageData = Allocator.arrayList(descriptors.size()); - for(int i = 0; i < descriptors.size(); i++) { + for (int i = 0; i < descriptors.size(); i++) { final ImageDescriptor descriptor = descriptors.get(i); if (descriptor == null) { throw new ImagingException(String.format("GIF: Couldn't read Image Descriptor of image number %d", i)); @@ -236,7 +236,7 @@ public class GifImageParser extends AbstractImageParser<GifImagingParameters> im final List<GifImageData> imageData = findAllImageData(imageContents); final List<BufferedImage> result = Allocator.arrayList(imageData.size()); - for(final GifImageData id : imageData) { + for (final GifImageData id : imageData) { result.add(getBufferedImage(ghi, id, imageContents.globalColorTable)); } return result; @@ -493,7 +493,7 @@ public class GifImageParser extends AbstractImageParser<GifImagingParameters> im final List<GifImageData> imageData = findAllImageData(imageContents); final List<GifImageMetadataItem> metadataItems = Allocator.arrayList(imageData.size()); - for(final GifImageData id : imageData) { + for (final GifImageData id : imageData) { final DisposalMethod disposalMethod = createDisposalMethodFromIntValue(id.gce.dispose); metadataItems.add(new GifImageMetadataItem(id.gce.delay, id.descriptor.imageLeftPosition, id.descriptor.imageTopPosition, disposalMethod)); } diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java index 56f4d096..f2b72eec 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java @@ -622,7 +622,7 @@ public class JpegDecoder extends BinaryFileParser implements JpegUtils.Visitor { * This extension to the JPEG specification is intended to support * TIFF files that use JPEG compression. */ - public void setTiffRgb(){ + public void setTiffRgb() { useTiffRgb = true; } } diff --git a/src/main/java/org/apache/commons/imaging/formats/png/PngImagingParameters.java b/src/main/java/org/apache/commons/imaging/formats/png/PngImagingParameters.java index 0cd6a0f9..f144d601 100644 --- a/src/main/java/org/apache/commons/imaging/formats/png/PngImagingParameters.java +++ b/src/main/java/org/apache/commons/imaging/formats/png/PngImagingParameters.java @@ -80,7 +80,7 @@ public class PngImagingParameters extends XmpImagingParameters<PngImagingParamet * the predictor. * @return true if the predictor is enabled; otherwise, false. */ - public boolean isPredictorEnabled(){ + public boolean isPredictorEnabled() { return predictorEnabled; } @@ -116,7 +116,7 @@ public class PngImagingParameters extends XmpImagingParameters<PngImagingParamet * @param predictorEnabled true if a predictor is enabled; otherwise, false. * @return this */ - public PngImagingParameters setPredictorEnabled(final boolean predictorEnabled){ + public PngImagingParameters setPredictorEnabled(final boolean predictorEnabled) { this.predictorEnabled = predictorEnabled; return asThis(); } diff --git a/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java b/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java index eed6b4a7..e3c09c79 100644 --- a/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java +++ b/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java @@ -474,8 +474,7 @@ public class PngWriter { // for non-grayscale, true-color images. This choice is made // out of caution and is not necessarily required by the PNG // spec. We may broaden the use of predictors in future versions. - final boolean usePredictor = params.isPredictorEnabled() && - !isGrayscale && palette==null; + final boolean usePredictor = params.isPredictorEnabled() && !isGrayscale && palette == null; byte[] uncompressed; if (!usePredictor) { diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java index 315c77f2..07d972b3 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java @@ -307,7 +307,7 @@ public class TiffField { public long[] getLongArrayValue() throws ImagingException { final Object o = getValue(); if (o instanceof Number) { - return new long[] { ((Number) o).longValue() }; + return new long[] { ((Number) o).longValue() }; } if (o instanceof Number[]) { final Number[] numbers = (Number[]) o; @@ -318,22 +318,21 @@ public class TiffField { if (o instanceof short[]) { final short[] numbers = (short[]) o; final long[] result = Allocator.longArray(numbers.length); - Arrays.setAll(result, i -> 0xffff & numbers[i]); + Arrays.setAll(result, i -> 0xffff & numbers[i]); return result; } if (o instanceof int[]) { final int[] numbers = (int[]) o; - final long[]result = Allocator.longArray(numbers.length); - Arrays.setAll(result, i -> 0xFFFFffffL & numbers[i]); + final long[] result = Allocator.longArray(numbers.length); + Arrays.setAll(result, i -> 0xFFFFffffL & numbers[i]); return result; } - if (o instanceof long[]){ - final long[] numbers = (long[]) o; - return Arrays.copyOf(numbers, numbers.length); + if (o instanceof long[]) { + final long[] numbers = (long[]) o; + return Arrays.copyOf(numbers, numbers.length); } - throw new ImagingException("Unknown value: " + o + " for: " - + getTagInfo().getDescription()); + throw new ImagingException("Unknown value: " + o + " for: " + getTagInfo().getDescription()); } /** @@ -342,15 +341,13 @@ public class TiffField { * @throws ImagingException if the field instance is of an incompatible type * or does not contain a valid data element. */ - public long getLongValue() throws ImagingException { - final Object o = getValue(); - if (o == null) { - throw new ImagingException("Missing value: " - + getTagInfo().getDescription()); - } - - return ((Number) o).longValue(); - } + public long getLongValue() throws ImagingException { + final Object o = getValue(); + if (o == null) { + throw new ImagingException("Missing value: " + getTagInfo().getDescription()); + } + return ((Number) o).longValue(); + } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java index dfe51fa3..ba04b0f6 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java @@ -57,17 +57,15 @@ public abstract class TiffRasterData { */ public TiffRasterData(final int width, final int height, final int samplesPerPixel) { if (width <= 0 || height <= 0) { - throw new IllegalArgumentException( - "Raster dimensions less than or equal to zero are not supported"); + throw new IllegalArgumentException("Raster dimensions less than or equal to zero are not supported"); } - if (samplesPerPixel <= 0){ - throw new IllegalArgumentException( - "Raster samples-per-pixel specification must be at least 1"); + if (samplesPerPixel <= 0) { + throw new IllegalArgumentException("Raster samples-per-pixel specification must be at least 1"); } this.width = width; this.height = height; this.samplesPerPixel = samplesPerPixel; - nCells = width*height*samplesPerPixel; + nCells = width * height * samplesPerPixel; planarOffset = width * height; } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataInterpreterJpeg.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataInterpreterJpeg.java index b361fcc1..acf14dc9 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataInterpreterJpeg.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataInterpreterJpeg.java @@ -136,7 +136,7 @@ final class DataInterpreterJpeg { // Limit iHeight and iWidth in case the JPEG block // extends past the output image size final int i1 = iHeight > blockHeight ? blockHeight : iHeight; - final int j1 = iWidth > blockWidth? blockWidth : iWidth; + final int j1 = iWidth > blockWidth ? blockWidth : iWidth; for (int i = 0; i < i1; i++) { for (int j = 0; j < j1; j++) { 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 3b1a5cd7..bc6dee19 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 @@ -308,8 +308,8 @@ public final class DataReaderStrips extends ImageDataReader { final byte[] compressed = imageData.getImageData(strip).getData(); if (compression == TIFF_COMPRESSION_JPEG) { - int yBlock = strip*rowsPerStrip; - int yWork = yBlock-y0; + int yBlock = strip * rowsPerStrip; + int yWork = yBlock - y0; DataInterpreterJpeg.intepretBlock(directory, workingBuilder, 0, yWork, width, (int)rowsInThisStrip, compressed); continue; diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java index 3469f384..05009a99 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java @@ -216,13 +216,13 @@ public abstract class ImageDataReader { return samples; } - protected void applyPredictorToBlock(final int width, final int height, final int nSamplesPerPixel, final byte []p ){ - final int k = width*nSamplesPerPixel; - for(int i=0; i<height; i++){ - final int j0 = i*k+nSamplesPerPixel; - final int j1 = (i+1)*k; - for(int j=j0; j<j1; j++){ - p[j]+=p[j-nSamplesPerPixel]; + protected void applyPredictorToBlock(final int width, final int height, final int nSamplesPerPixel, final byte[] p) { + final int k = width * nSamplesPerPixel; + for (int i = 0; i < height; i++) { + final int j0 = i * k + nSamplesPerPixel; + final int j1 = (i + 1) * k; + for (int j = j0; j < j1; j++) { + p[j] += p[j - nSamplesPerPixel]; } } } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java index b950c67c..38082c5f 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java @@ -130,11 +130,11 @@ public final class T4AndT6Compression { } private static int compressT(final int a0, final int a1, final int b1, final BitArrayOutputStream outputStream, final int codingA0Color, - final int[] codingLine){ - final int a1b1 = a1 - b1; - if (-3 <= a1b1 && a1b1 <= 3) { - T4_T6_Tables.Entry entry; - switch (a1b1) { + final int[] codingLine) { + final int a1b1 = a1 - b1; + if (-3 <= a1b1 && a1b1 <= 3) { + T4_T6_Tables.Entry entry; + switch (a1b1) { case -3: entry = T4_T6_Tables.VL3; break; @@ -157,17 +157,16 @@ public final class T4AndT6Compression { entry = T4_T6_Tables.VR3; break; } - entry.writeBits(outputStream); - return a1; - - } + entry.writeBits(outputStream); + return a1; + } final int a2 = nextChangingElement(codingLine, 1 - codingA0Color, a1 + 1); - final int a0a1 = a1 - a0; - final int a1a2 = a2 - a1; - T4_T6_Tables.H.writeBits(outputStream); - writeRunLength(outputStream, a0a1, codingA0Color); - writeRunLength(outputStream, a1a2, 1 - codingA0Color); - return a2; + final int a0a1 = a1 - a0; + final int a1a2 = a2 - a1; + T4_T6_Tables.H.writeBits(outputStream); + writeRunLength(outputStream, a0a1, codingA0Color); + writeRunLength(outputStream, a1a2, 1 - codingA0Color); + return a2; } public static byte[] compressT4_1D(final byte[] uncompressed, final int width, diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java index 52aeb9ac..1e1b1c80 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java @@ -59,7 +59,7 @@ import org.apache.commons.imaging.mylzw.MyLzwCompressor; public abstract class AbstractTiffImageWriter { - private static final int MAX_PIXELS_FOR_RGB = 1024*1024; + private static final int MAX_PIXELS_FOR_RGB = 1024 * 1024; protected static int imageDataPaddingLength(final int dataLength) { return (4 - (dataLength % 4)) % 4; @@ -135,8 +135,7 @@ public abstract class AbstractTiffImageWriter { } } - private byte[][] getStrips(final BufferedImage src, final int samplesPerPixel, - final int bitsPerSample, final int rowsPerStrip) { + private byte[][] getStrips(final BufferedImage src, final int samplesPerPixel, final int bitsPerSample, final int rowsPerStrip) { final int width = src.getWidth(); final int height = src.getHeight(); @@ -186,11 +185,11 @@ public abstract class AbstractTiffImageWriter { bitCache = 0; bitsInCache = 0; } - } else if (samplesPerPixel==4){ + } else if (samplesPerPixel == 4) { uncompressed[counter++] = (byte) red; uncompressed[counter++] = (byte) green; uncompressed[counter++] = (byte) blue; - uncompressed[counter++] = (byte) (rgb>>24); + uncompressed[counter++] = (byte) (rgb >> 24); } else { // samples per pixel is 3 uncompressed[counter++] = (byte) red; @@ -422,12 +421,11 @@ public abstract class AbstractTiffImageWriter { final ColorModel cModel = src.getColorModel(); final boolean hasAlpha = cModel.hasAlpha() && checkForActualAlpha(src); - // 10/2020: In the case of an image with pre-multiplied alpha // (what the TIFF specification calls "associated alpha"), the // Java getRGB method adjusts the value to a non-premultiplied - // alpha state. However, this class could access the pre-multiplied - // alpha data by obtaining the underlying raster. At this time, + // alpha state. However, this class could access the pre-multiplied + // alpha data by obtaining the underlying raster. At this time, // the value of such a little-used feature does not seem // commensurate with the complexity of the extra code it would require. @@ -441,9 +439,7 @@ public abstract class AbstractTiffImageWriter { final Integer stripSizeInBytes = params.getLzwCompressionBlockSize(); if (stripSizeInBytes != null) { if (stripSizeInBytes < 8000) { - throw new ImagingException( - "Block size parameter " + stripSizeInBytes - + " is less than 8000 minimum"); + throw new ImagingException("Block size parameter " + stripSizeInBytes + " is less than 8000 minimum"); } stripSizeInBits = stripSizeInBytes * 8; } @@ -452,14 +448,12 @@ public abstract class AbstractTiffImageWriter { int samplesPerPixel; int bitsPerSample; int photometricInterpretation; - if (compression == TIFF_COMPRESSION_CCITT_1D - || compression == TIFF_COMPRESSION_CCITT_GROUP_3 - || compression == TIFF_COMPRESSION_CCITT_GROUP_4) { + if (compression == TIFF_COMPRESSION_CCITT_1D || compression == TIFF_COMPRESSION_CCITT_GROUP_3 || compression == TIFF_COMPRESSION_CCITT_GROUP_4) { samplesPerPixel = 1; bitsPerSample = 1; photometricInterpretation = 0; } else { - samplesPerPixel = hasAlpha? 4: 3; + samplesPerPixel = hasAlpha ? 4 : 3; bitsPerSample = 8; photometricInterpretation = 2; } @@ -492,19 +486,14 @@ public abstract class AbstractTiffImageWriter { final boolean is2D = (t4Options & 1) != 0; final boolean usesUncompressedMode = (t4Options & 2) != 0; if (usesUncompressedMode) { - throw new ImagingException( - "T.4 compression with the uncompressed mode extension is not yet supported"); + throw new ImagingException("T.4 compression with the uncompressed mode extension is not yet supported"); } final boolean hasFillBitsBeforeEOL = (t4Options & 4) != 0; for (int i = 0; i < strips.length; i++) { if (is2D) { - strips[i] = T4AndT6Compression.compressT4_2D(strips[i], - width, strips[i].length / ((width + 7) / 8), - hasFillBitsBeforeEOL, rowsPerStrip); + strips[i] = T4AndT6Compression.compressT4_2D(strips[i], width, strips[i].length / ((width + 7) / 8), hasFillBitsBeforeEOL, rowsPerStrip); } else { - strips[i] = T4AndT6Compression.compressT4_1D(strips[i], - width, strips[i].length / ((width + 7) / 8), - hasFillBitsBeforeEOL); + strips[i] = T4AndT6Compression.compressT4_1D(strips[i], width, strips[i].length / ((width + 7) / 8), hasFillBitsBeforeEOL); } } break; @@ -517,8 +506,7 @@ public abstract class AbstractTiffImageWriter { t6Options &= 0x4; final boolean usesUncompressedMode = (t6Options & TIFF_FLAG_T6_OPTIONS_UNCOMPRESSED_MODE) != 0; if (usesUncompressedMode) { - throw new ImagingException( - "T.6 compression with the uncompressed mode extension is not yet supported"); + throw new ImagingException("T.6 compression with the uncompressed mode extension is not yet supported"); } for (int i = 0; i < strips.length; i++) { strips[i] = T4AndT6Compression.compressT6(strips[i], width, strips[i].length / ((width + 7) / 8)); @@ -531,14 +519,13 @@ public abstract class AbstractTiffImageWriter { } break; case TIFF_COMPRESSION_LZW: - predictor = TiffTagConstants.PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING; + predictor = TiffTagConstants.PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING; for (int i = 0; i < strips.length; i++) { final byte[] uncompressed = strips[i]; this.applyPredictor(width, samplesPerPixel, strips[i]); final int LZW_MINIMUM_CODE_SIZE = 8; - final MyLzwCompressor compressor = new MyLzwCompressor( - LZW_MINIMUM_CODE_SIZE, ByteOrder.BIG_ENDIAN, true); + final MyLzwCompressor compressor = new MyLzwCompressor(LZW_MINIMUM_CODE_SIZE, ByteOrder.BIG_ENDIAN, true); final byte[] compressed = compressor.compress(uncompressed); strips[i] = compressed; } @@ -569,29 +556,21 @@ public abstract class AbstractTiffImageWriter { directory.add(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, width); directory.add(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, height); - directory.add(TiffTagConstants.TIFF_TAG_PHOTOMETRIC_INTERPRETATION, - (short) photometricInterpretation); - directory.add(TiffTagConstants.TIFF_TAG_COMPRESSION, - (short) compression); - directory.add(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL, - (short) samplesPerPixel); + directory.add(TiffTagConstants.TIFF_TAG_PHOTOMETRIC_INTERPRETATION, (short) photometricInterpretation); + directory.add(TiffTagConstants.TIFF_TAG_COMPRESSION, (short) compression); + directory.add(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL, (short) samplesPerPixel); switch (samplesPerPixel) { case 3: - directory.add(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, - (short) bitsPerSample, (short) bitsPerSample, - (short) bitsPerSample); + directory.add(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, (short) bitsPerSample, (short) bitsPerSample, (short) bitsPerSample); break; case 4: - directory.add(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, - (short) bitsPerSample, (short) bitsPerSample, - (short) bitsPerSample, (short) bitsPerSample); - directory.add(TiffTagConstants.TIFF_TAG_EXTRA_SAMPLES, - (short)TiffTagConstants.EXTRA_SAMPLE_UNASSOCIATED_ALPHA); + directory.add(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, (short) bitsPerSample, (short) bitsPerSample, (short) bitsPerSample, + (short) bitsPerSample); + directory.add(TiffTagConstants.TIFF_TAG_EXTRA_SAMPLES, (short) TiffTagConstants.EXTRA_SAMPLE_UNASSOCIATED_ALPHA); break; case 1: - directory.add(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, - (short) bitsPerSample); + directory.add(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, (short) bitsPerSample); break; default: break; @@ -609,29 +588,19 @@ public abstract class AbstractTiffImageWriter { // WRITE_BYTE_ORDER)); // directory.add(field); // } - directory.add(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP, - rowsPerStrip); + directory.add(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP, rowsPerStrip); if (pixelDensity.isUnitless()) { - directory.add(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT, - (short) 0); - directory.add(TiffTagConstants.TIFF_TAG_XRESOLUTION, - RationalNumber.valueOf(pixelDensity.getRawHorizontalDensity())); - directory.add(TiffTagConstants.TIFF_TAG_YRESOLUTION, - RationalNumber.valueOf(pixelDensity.getRawVerticalDensity())); + directory.add(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT, (short) 0); + directory.add(TiffTagConstants.TIFF_TAG_XRESOLUTION, RationalNumber.valueOf(pixelDensity.getRawHorizontalDensity())); + directory.add(TiffTagConstants.TIFF_TAG_YRESOLUTION, RationalNumber.valueOf(pixelDensity.getRawVerticalDensity())); } else if (pixelDensity.isInInches()) { - directory.add(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT, - (short) 2); - directory.add(TiffTagConstants.TIFF_TAG_XRESOLUTION, - RationalNumber.valueOf(pixelDensity.horizontalDensityInches())); - directory.add(TiffTagConstants.TIFF_TAG_YRESOLUTION, - RationalNumber.valueOf(pixelDensity.verticalDensityInches())); + directory.add(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT, (short) 2); + directory.add(TiffTagConstants.TIFF_TAG_XRESOLUTION, RationalNumber.valueOf(pixelDensity.horizontalDensityInches())); + directory.add(TiffTagConstants.TIFF_TAG_YRESOLUTION, RationalNumber.valueOf(pixelDensity.verticalDensityInches())); } else { - directory.add(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT, - (short) 1); - directory.add(TiffTagConstants.TIFF_TAG_XRESOLUTION, - RationalNumber.valueOf(pixelDensity.horizontalDensityCentimetres())); - directory.add(TiffTagConstants.TIFF_TAG_YRESOLUTION, - RationalNumber.valueOf(pixelDensity.verticalDensityCentimetres())); + directory.add(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT, (short) 1); + directory.add(TiffTagConstants.TIFF_TAG_XRESOLUTION, RationalNumber.valueOf(pixelDensity.horizontalDensityCentimetres())); + directory.add(TiffTagConstants.TIFF_TAG_YRESOLUTION, RationalNumber.valueOf(pixelDensity.verticalDensityCentimetres())); } if (t4Options != 0) { directory.add(TiffTagConstants.TIFF_TAG_T4_OPTIONS, t4Options); @@ -645,14 +614,13 @@ public abstract class AbstractTiffImageWriter { directory.add(TiffTagConstants.TIFF_TAG_XMP, xmpXmlBytes); } - if (predictor == TiffTagConstants.PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING){ + if (predictor == TiffTagConstants.PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING) { directory.add(TiffTagConstants.TIFF_TAG_PREDICTOR, predictor); } } - final AbstractTiffImageData abstractTiffImageData = new AbstractTiffImageData.Strips(imageData, - rowsPerStrip); + final AbstractTiffImageData abstractTiffImageData = new AbstractTiffImageData.Strips(imageData, rowsPerStrip); directory.setTiffImageData(abstractTiffImageData); if (userExif != null) { diff --git a/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java b/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java index a9857bcc..789e6a33 100644 --- a/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java +++ b/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java @@ -70,5 +70,6 @@ public class ImageParserFactory { return getImageParser(parser -> parser.canAcceptExtension(fileExtension), () -> new IllegalArgumentException("Unknown extension: " + fileExtension)); } - private ImageParserFactory() {} + private ImageParserFactory() { + } }