Apache Commons logo Commons Imaging™ logo

CPD Results

The following document contains the results of PMD's CPD 6.55.0.

Duplications

File Line
org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java 441
org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java 538
entry = CONTROL_CODES.decode(inputStream);
                            if (entry == T4_T6_Tables.P) {
                                fillRange(outputStream, referenceLine, a0, b2, codingA0Color);
                                a0 = b2;
                            } else if (entry == T4_T6_Tables.H) {
                                final int a0a1 = readTotalRunLength(inputStream, codingA0Color);
                                a1 = a0 + a0a1;
                                fillRange(outputStream, referenceLine, a0, a1, codingA0Color);
                                final int a1a2 = readTotalRunLength(inputStream, 1 - codingA0Color);
                                a2 = a1 + a1a2;
                                fillRange(outputStream, referenceLine, a1, a2, 1 - codingA0Color);
                                a0 = a2;
                            } else {
                                int a1b1;
                                if (entry == T4_T6_Tables.V0) {
                                    a1b1 = 0;
                                } else if (entry == T4_T6_Tables.VL1) {
                                    a1b1 = -1;
                                } else if (entry == T4_T6_Tables.VL2) {
                                    a1b1 = -2;
                                } else if (entry == T4_T6_Tables.VL3) {
                                    a1b1 = -3;
                                } else if (entry == T4_T6_Tables.VR1) {
                                    a1b1 = 1;
                                } else if (entry == T4_T6_Tables.VR2) {
                                    a1b1 = 2;
                                } else if (entry == T4_T6_Tables.VR3) {
                                    a1b1 = 3;
                                } else {
                                    throw new ImagingException("Invalid/unknown T.4 control code " + entry.bitString);
File Line
org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java 218
org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java 286
throw new ImagingException("Error reading image to compress", ioException);
                    }
                }
                int codingA0Color = WHITE;
                int referenceA0Color = WHITE;
                int a1 = nextChangingElement(codingLine, codingA0Color, 0);
                int b1 = nextChangingElement(referenceLine, referenceA0Color, 0);
                int b2 = nextChangingElement(referenceLine, 1 - referenceA0Color, b1 + 1);
                for (int a0 = 0; a0 < width;) {
                    if (b2 < a1) {
                        T4_T6_Tables.P.writeBits(outputStream);
                        a0 = b2;
                    } else {
                        a0 = compressT(a0, a1, b1, outputStream, codingA0Color, codingLine);
                        if (a0 == a1) {
                            codingA0Color = 1 - codingA0Color;
                        }
                    }
                    referenceA0Color = changingElementAt(referenceLine, a0);
                    a1 = nextChangingElement(codingLine, codingA0Color, a0 + 1);
                    if (codingA0Color == referenceA0Color) {
                        b1 = nextChangingElement(referenceLine, referenceA0Color, a0 + 1);
                    } else {
                        b1 = nextChangingElement(referenceLine, referenceA0Color, a0 + 1);
                        b1 = nextChangingElement(referenceLine, 1 - referenceA0Color, b1 + 1);
                    }
                    b2 = nextChangingElement(referenceLine, 1 - codingA0Color, b1 + 1);
                }
                final int[] swap = referenceLine;
                referenceLine = codingLine;
                codingLine = swap;
File Line
org/apache/commons/imaging/formats/tiff/TiffRasterDataFloat.java 160
org/apache/commons/imaging/formats/tiff/TiffRasterDataInt.java 159
return (int) data[index];
    }

    /**
     * Tabulates simple statistics for the raster and returns an instance containing general metadata.
     *
     * @return a valid instance containing a safe copy of the current simple statistics for the raster.
     */
    @Override
    public TiffRasterStatistics getSimpleStatistics() {
        return new TiffRasterStatistics(this, Float.NaN);
    }

    /**
     * Tabulates simple statistics for the raster excluding the specified value and returns an instance containing general metadata.
     *
     * @param valueToExclude exclude samples with this specified value.
     * @return a valid instance.
     */
    @Override
    public TiffRasterStatistics getSimpleStatistics(final float valueToExclude) {
        return new TiffRasterStatistics(this, valueToExclude);
    }

    /**
     * Gets the value stored at the specified raster coordinates.
     *
     * @param x integer coordinate in the columnar direction
     * @param y integer coordinate in the row direction
     * @return the value stored at the specified location; potentially a Float&#46;NaN.
     */
    @Override
    public float getValue(final int x, final int y) {
        final int index = checkCoordinatesAndComputeIndex(x, y, 0);
        return data[index];
    }

    /**
     * Gets the value stored at the specified raster coordinates.
     *
     * @param x integer coordinate in the columnar direction
     * @param y integer coordinate in the row direction
     * @param i integer sample index (for data sets giving multiple samples per raster cell).
     * @return the value stored at the specified location; potentially a Float&#46;NaN.
     */
    @Override
    public float getValue(final int x, final int y, final int i) {
        final int index = checkCoordinatesAndComputeIndex(x, y, i);
        return data[index];
    }

    /**
     * Sets the value stored at the specified raster coordinates.
     *
     * @param x     integer coordinate in the columnar direction
     * @param y     integer coordinate in the row direction
     * @param value the value to be stored at the specified location
     */
    @Override
    public void setIntValue(final int x, final int y, final int value) {
        final int index = checkCoordinatesAndComputeIndex(x, y, 0);
        data[index] = value;
    }

    /**
     * Sets the value stored at the specified raster coordinates.
     *
     * @param x     integer coordinate in the columnar direction
     * @param y     integer coordinate in the row direction
     * @param i     integer sample index (for data sets giving multiple samples per raster cell).
     * @param value the value to be stored at the specified location
     */
    @Override
    public void setIntValue(final int x, final int y, final int i, final int value) {
        final int index = checkCoordinatesAndComputeIndex(x, y, 0);
File Line
org/apache/commons/imaging/formats/pnm/PgmWriter.java 39
org/apache/commons/imaging/formats/pnm/PpmWriter.java 39
os.write(rawBits ? 0x35 : 0x32);
        os.write(PnmConstants.PNM_SEPARATOR);

        final int width = src.getWidth();
        final int height = src.getHeight();

        os.write(Integer.toString(width).getBytes(StandardCharsets.US_ASCII));
        os.write(PnmConstants.PNM_SEPARATOR);

        os.write(Integer.toString(height).getBytes(StandardCharsets.US_ASCII));
        os.write(PnmConstants.PNM_SEPARATOR);

        os.write(Integer.toString(255).getBytes(StandardCharsets.US_ASCII)); // max component value
        os.write(PnmConstants.PNM_NEWLINE);

        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                final int argb = src.getRGB(x, y);
                final int red = 0xff & argb >> 16;
                final int green = 0xff & argb >> 8;
                final int blue = 0xff & argb >> 0;
File Line
org/apache/commons/imaging/color/ColorCieLab.java 105
org/apache/commons/imaging/color/ColorHunterLab.java 105
final ColorCieLab that = (ColorCieLab) o;
        if (Double.compare(that.l, l) != 0) {
            return false;
        }
        if (Double.compare(that.a, a) != 0) {
            return false;
        }
        if (Double.compare(that.b, b) != 0) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result;
        long temp;
        temp = Double.doubleToLongBits(l);
        result = (int) (temp ^ temp >>> 32);
        temp = Double.doubleToLongBits(a);
        result = 31 * result + (int) (temp ^ temp >>> 32);
        temp = Double.doubleToLongBits(b);
        return 31 * result + (int) (temp ^ temp >>> 32);
    }

    @Override
    public String toString() {
        return "{L: " + l + ", a: " + a + ", b: " + b + "}";
    }
}
File Line
org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java 359
org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java 476
final int yRaster, final int rasterWidth, final int rasterHeight, final int samplesPerPixel, final float[] rasterData) {

        // xR0, yR0 are the coordinates within the raster (upper-left corner)
        // xR1, yR1 are ONE PAST the coordinates of the lower-right corner
        int xR0 = xBlock - xRaster; // xR0, yR0 coordinates relative to
        int yR0 = yBlock - yRaster; // the raster
        int xR1 = xR0 + blockWidth;
        int yR1 = yR0 + blockHeight;
        if (xR0 < 0) {
            xR0 = 0;
        }
        if (yR0 < 0) {
            yR0 = 0;
        }
        if (xR1 > rasterWidth) {
            xR1 = rasterWidth;
        }
        if (yR1 > rasterHeight) {
            yR1 = rasterHeight;
        }

        // Recall that the above logic may have adjusted xR0, xY0 so that
        // they are not necessarily point to the source pixel at xRaster, yRaster
        // we compute xSource = xR0+xRaster.
        // xOffset = xSource-xBlock
        // since the block cannot be accessed with a negative offset,
        // we check for negatives and adjust xR0, yR0 upward as necessary
        int xB0 = xR0 + xRaster - xBlock;
        int yB0 = yR0 + yRaster - yBlock;
        if (xB0 < 0) {
            xR0 -= xB0;
            xB0 = 0;
        }
        if (yB0 < 0) {
            yR0 -= yB0;
            yB0 = 0;
        }

        int w = xR1 - xR0;
        int h = yR1 - yR0;
        if (w <= 0 || h <= 0) {
            // The call to this method put the block outside the
            // bounds of the raster. There is nothing to do. Ideally,
            // this situation never arises, because it would mean that
            // the data was read from the file unnecessarily.
            return;
        }
        // see if the xR1, yR1 would extend past the limits of the block
        if (w > blockWidth) {
            w = blockWidth;
        }
        if (h > blockHeight) {
            h = blockHeight;
        }
File Line
org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java 37
org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong8.java 46
return ByteConversions.toInts(bytes, entry.getByteOrder());
    }

    @Override
    public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImagingException {
        if (o instanceof Integer) {
            return ByteConversions.toBytes((Integer) o, byteOrder);
        }
        if (o instanceof int[]) {
            final int[] numbers = (int[]) o;
            return ByteConversions.toBytes(numbers, byteOrder);
        }
        if (!(o instanceof Integer[])) {
            throw new ImagingException("Invalid data", o);
        }
        final Integer[] numbers = (Integer[]) o;
        final int[] values = Allocator.intArray(numbers.length);
        System.arraycopy(numbers, 0, values, 0, values.length);
        return ByteConversions.toBytes(values, byteOrder);
    }

}
File Line
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java 304
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java 350
final float[] rasterDataFloat = Allocator.floatArray(rasterWidth * rasterHeight * samplesPerPixel);

        // tileWidth is the width of the tile
        // tileLength is the height of the tile
        final int col0 = xRaster / tileWidth;
        final int col1 = (xRaster + rasterWidth - 1) / tileWidth;
        final int row0 = yRaster / tileLength;
        final int row1 = (yRaster + rasterHeight - 1) / tileLength;

        final int nColumnsOfTiles = (width + tileWidth - 1) / tileWidth;

        for (int iRow = row0; iRow <= row1; iRow++) {
            for (int iCol = col0; iCol <= col1; iCol++) {
                final int tile = iRow * nColumnsOfTiles + iCol;
                final byte[] compressed = imageData.tiles[tile].getData();
                final byte[] decompressed = decompress(compressed, compression, bytesPerTile, tileWidth, tileLength);
                final int x = iCol * tileWidth;
                final int y = iRow * tileLength;

                final int[] blockData = unpackFloatingPointSamples(tileWidth, tileLength, tileWidth, decompressed, bitsPerPixel, byteOrder);
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 315
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 412
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 466
public int getFieldValue(final TagInfoLong tag) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            throw new ImagingException("Required field \"" + tag.name + "\" is missing");
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
        }
        if (field.getCount() != 1) {
            throw new ImagingException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public int[] getFieldValue(final TagInfoLongs tag, final boolean mustExist) throws ImagingException {
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 348
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 499
public RationalNumber getFieldValue(final TagInfoRational tag) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            throw new ImagingException("Required field \"" + tag.name + "\" is missing");
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
        }
        if (field.getCount() != 1) {
            throw new ImagingException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public RationalNumber[] getFieldValue(final TagInfoRationals tag, final boolean mustExist) throws ImagingException {
File Line
org/apache/commons/imaging/palette/LongestAxisMedianCut.java 37
org/apache/commons/imaging/palette/MostPopulatedBoxesMedianCut.java 51
colorCounts.sort(new ColorCountComparator(mode));
        final int countHalf = (int) Math.round((double) colorGroup.totalPoints / 2);
        int oldCount = 0;
        int newCount = 0;
        int medianIndex;
        for (medianIndex = 0; medianIndex < colorCounts.size(); medianIndex++) {
            final ColorCount colorCount = colorCounts.get(medianIndex);

            newCount += colorCount.count;

            if (newCount >= countHalf) {
                break;
            }
            oldCount = newCount;
        }

        if (medianIndex == colorCounts.size() - 1) {
            medianIndex--;
        } else if (medianIndex > 0) {
            final int newDiff = Math.abs(newCount - countHalf);
            final int oldDiff = Math.abs(countHalf - oldCount);
            if (oldDiff < newDiff) {
                medianIndex--;
            }
        }
File Line
org/apache/commons/imaging/formats/tiff/TiffImageParser.java 254
org/apache/commons/imaging/formats/tiff/TiffImageParser.java 759
final Rectangle subImage = checkForSubImage(params);
        if (subImage != null) {
            // Check for valid subimage specification. The following checks
            // are consistent with BufferedImage.getSubimage()
            if (subImage.width <= 0) {
                throw new ImagingException("Negative or zero subimage width.");
            }
            if (subImage.height <= 0) {
                throw new ImagingException("Negative or zero subimage height.");
            }
            if (subImage.x < 0 || subImage.x >= width) {
                throw new ImagingException("Subimage x is outside raster.");
            }
            if (subImage.x + subImage.width > width) {
                throw new ImagingException("Subimage (x+width) is outside raster.");
            }
            if (subImage.y < 0 || subImage.y >= height) {
                throw new ImagingException("Subimage y is outside raster.");
            }
            if (subImage.y + subImage.height > height) {
                throw new ImagingException("Subimage (y+height) is outside raster.");
            }
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 238
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 271
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 315
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 348
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 412
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 466
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 499
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 532
public double getFieldValue(final TagInfoDouble tag) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            throw new ImagingException("Required field \"" + tag.name + "\" is missing");
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
        }
        if (field.getCount() != 1) {
            throw new ImagingException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public double[] getFieldValue(final TagInfoDoubles tag, final boolean mustExist) throws ImagingException {
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 189
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 363
public String[] getFieldValue(final TagInfoAscii tag, final boolean mustExist) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" is missing");
            }
            return null;
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
            }
            return null;
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public byte getFieldValue(final TagInfoByte tag) throws ImagingException {
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 286
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 547
public float[] getFieldValue(final TagInfoFloats tag, final boolean mustExist) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" is missing");
            }
            return null;
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
            }
            return null;
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public String getFieldValue(final TagInfoGpsText tag, final boolean mustExist) throws ImagingException {
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 330
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 481
public int[] getFieldValue(final TagInfoLongs tag, final boolean mustExist) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" is missing");
            }
            return null;
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
            }
            return null;
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public RationalNumber getFieldValue(final TagInfoRational tag) throws ImagingException {
File Line
org/apache/commons/imaging/formats/xbm/XbmImageParser.java 97
org/apache/commons/imaging/formats/xpm/XpmImageParser.java 486
private static String randomName() {
        final UUID uuid = UUID.randomUUID();
        final StringBuilder stringBuilder = new StringBuilder("a");
        long bits = uuid.getMostSignificantBits();
        // Long.toHexString() breaks for very big numbers
        for (int i = 64 - 8; i >= 0; i -= 8) {
            stringBuilder.append(Integer.toHexString((int) (bits >> i & 0xff)));
        }
        bits = uuid.getLeastSignificantBits();
        for (int i = 64 - 8; i >= 0; i -= 8) {
            stringBuilder.append(Integer.toHexString((int) (bits >> i & 0xff)));
        }
        return stringBuilder.toString();
    }

    private static String toPrettyHex(final int value) {
File Line
org/apache/commons/imaging/color/ColorConversions.java 554
org/apache/commons/imaging/color/ColorConversions.java 617
final double delR = ((varMax - varR) / 6 + delMax / 2) / delMax;
            final double delG = ((varMax - varG) / 6 + delMax / 2) / delMax;
            final double delB = ((varMax - varB) / 6 + delMax / 2) / delMax;

            if (maxIsR) {
                h = delB - delG;
            } else if (maxIsG) {
                h = 1 / 3.0 + delR - delB;
            } else {
                h = 2 / 3.0 + delG - delR;
            }

            // Debug.debug("H1", H);

            if (h < 0) {
                h += 1;
            }
            if (h > 1) {
                h -= 1;
            }

            // Debug.debug("H2", H);
        }

        return new ColorHsl(h, s, l);
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 207
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 381
public byte getFieldValue(final TagInfoByte tag) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            throw new ImagingException("Required field \"" + tag.name + "\" is missing");
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
        }
        if (field.getCount() != 1) {
            throw new ImagingException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
        }
        return field.getByteArrayValue()[0];
    }

    public byte[] getFieldValue(final TagInfoBytes tag, final boolean mustExist) throws ImagingException {
File Line
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java 366
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java 411
final float[] rasterDataFloat = Allocator.floatArray(rasterWidth * rasterHeight * samplesPerPixel);

        // the legacy code is optimized to the reading of whole
        // strips (except for the last strip in the image, which can
        // be a partial). So create a working image with compatible
        // dimensions and read that. Later on, the working image
        // will be sub-imaged to the proper size.
        // strip0 and strip1 give the indices of the strips containing
        // the first and last rows of pixels in the subimage
        final int strip0 = yRaster / rowsPerStrip;
        final int strip1 = (yRaster + rasterHeight - 1) / rowsPerStrip;

        for (int strip = strip0; strip <= strip1; strip++) {
            final int yStrip = strip * rowsPerStrip;
            final int rowsRemaining = height - yStrip;
            final int rowsInThisStrip = Math.min(rowsRemaining, rowsPerStrip);
            final int bytesPerRow = (bitsPerPixel * width + 7) / 8;
            final int bytesPerStrip = rowsInThisStrip * bytesPerRow;

            final byte[] compressed = imageData.getImageData(strip).getData();
            final byte[] decompressed = decompress(compressed, compression, bytesPerStrip, width, rowsInThisStrip);

            final int[] blockData = unpackFloatingPointSamples(width, rowsInThisStrip, width, decompressed, bitsPerPixel, byteOrder);
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 189
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 253
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 286
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 330
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 363
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 448
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 481
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 514
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 547
public String[] getFieldValue(final TagInfoAscii tag, final boolean mustExist) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" is missing");
            }
            return null;
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
            }
            return null;
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public byte getFieldValue(final TagInfoByte tag) throws ImagingException {
File Line
org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java 43
org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java 43
final String[] strings = Allocator.array(nullCount, String[]::new, 24);
        int stringsAdded = 0;
        strings[0] = ""; // if we have a 0 length string
        int nextStringPos = 0;
        // According to the Exiftool FAQ, [BROKEN URL] http://www.metadataworkinggroup.org
        // specifies that the TIFF ASCII fields are actually UTF-8.
        // Exiftool however allows you to configure the charset used.
        for (int i = 0; i < bytes.length; i++) {
            if (bytes[i] == 0) {
                final String string = new String(bytes, nextStringPos, i - nextStringPos, StandardCharsets.UTF_8);
                strings[stringsAdded++] = string;
                nextStringPos = i + 1;
            }
        }
        if (nextStringPos < bytes.length) {
            // Buggy file, string wasn't null terminated
            final String string = new String(bytes, nextStringPos, bytes.length - nextStringPos, StandardCharsets.UTF_8);
            strings[stringsAdded++] = string;
        }
File Line
org/apache/commons/imaging/palette/ColorSpaceSubset.java 107
org/apache/commons/imaging/palette/ColorSpaceSubset.java 116
LOGGER.fine("\t" + "rgb: " + Integer.toHexString(rgb) + ", " + "red: " + Integer.toHexString(mins[0] << 8 - precision) + ", "
                + Integer.toHexString(maxs[0] << 8 - precision) + ", " + "green: " + Integer.toHexString(mins[1] << 8 - precision) + ", "
                + Integer.toHexString(maxs[1] << 8 - precision) + ", " + "blue: " + Integer.toHexString(mins[2] << 8 - precision) + ", "
                + Integer.toHexString(maxs[2] << 8 - precision));
File Line
org/apache/commons/imaging/formats/pcx/PcxWriter.java 206
org/apache/commons/imaging/formats/pcx/PcxWriter.java 214
} else if (bitDepth == 1 && planes == 3) {
                for (int x = 0; x < src.getWidth(); x++) {
                    final int argb = src.getRGB(x, y);
                    final int index = palette.getPaletteIndex(0xffffff & argb);
                    plane0[x >>> 3] |= (index & 1) << 7 - (x & 7);
                    plane1[x >>> 3] |= (index & 2) >> 1 << 7 - (x & 7);
                    plane2[x >>> 3] |= (index & 4) >> 2 << 7 - (x & 7);
File Line
org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java 111
org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java 124
public int getArgb(final float f) {
        if (v0 <= f && f <= v1) {
            final float t = (f - v0) / (v1 - v0);
            final int a = (int) (t * (a1 - a0) + a0 + 0.5);
            final int r = (int) (t * (r1 - r0) + r0 + 0.5);
            final int g = (int) (t * (g1 - g0) + g0 + 0.5);
            final int b = (int) (t * (b1 - b0) + b0 + 0.5);
            return ((a << 8 | r) << 8 | g) << 8 | b;
File Line
org/apache/commons/imaging/common/ByteConversions.java 239
org/apache/commons/imaging/common/ByteConversions.java 334
private static double toDouble(final byte[] bytes, final int offset, final ByteOrder byteOrder) {
        final long byte0 = 0xffL & bytes[offset + 0];
        final long byte1 = 0xffL & bytes[offset + 1];
        final long byte2 = 0xffL & bytes[offset + 2];
        final long byte3 = 0xffL & bytes[offset + 3];
        final long byte4 = 0xffL & bytes[offset + 4];
        final long byte5 = 0xffL & bytes[offset + 5];
        final long byte6 = 0xffL & bytes[offset + 6];
        final long byte7 = 0xffL & bytes[offset + 7];
File Line
org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java 470
org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java 567
throw new ImagingException("Invalid/unknown T.4 control code " + entry.bitString);
                                }
                                a1 = b1 + a1b1;
                                fillRange(outputStream, referenceLine, a0, a1, codingA0Color);
                                a0 = a1;
                                codingA0Color = 1 - codingA0Color;
                            }
                            referenceA0Color = changingElementAt(referenceLine, a0);
                            if (codingA0Color == referenceA0Color) {
                                b1 = nextChangingElement(referenceLine, referenceA0Color, a0 + 1);
                            } else {
                                b1 = nextChangingElement(referenceLine, referenceA0Color, a0 + 1);
                                b1 = nextChangingElement(referenceLine, 1 - referenceA0Color, b1 + 1);
                            }
                            b2 = nextChangingElement(referenceLine, 1 - codingA0Color, b1 + 1);
                            rowLength = a0;
                        }
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 189
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 253
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 286
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 330
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 363
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 427
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 448
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 481
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 514
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 547
public String[] getFieldValue(final TagInfoAscii tag, final boolean mustExist) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" is missing");
            }
            return null;
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
            }
            return null;
        }
        final byte[] bytes = field.getByteArrayValue();
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 207
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 238
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 271
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 315
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 348
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 381
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 412
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 466
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 499
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 532
public byte getFieldValue(final TagInfoByte tag) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            throw new ImagingException("Required field \"" + tag.name + "\" is missing");
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
        }
        if (field.getCount() != 1) {
            throw new ImagingException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
        }
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 221
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 395
public byte[] getFieldValue(final TagInfoBytes tag, final boolean mustExist) throws ImagingException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" is missing");
            }
            return null;
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImagingException("Required field \"" + tag.name + "\" has incorrect type " + field.getFieldType().getName());
            }
            return null;
        }
        return field.getByteArrayValue();
    }

    public double getFieldValue(final TagInfoDouble tag) throws ImagingException {