CPD Results

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

Duplications

File Line
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java 281
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java 512
                for (int i = 0; i < width; i++) {
                    try {
                        codingLine[i] = inputStream.readBits(1);
                    } catch (final IOException ioException) {
                        throw new ImageWriteException(
                                "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 {
                        final int a1b1 = a1 - b1;
                        if (-3 <= a1b1 && a1b1 <= 3) {
                            T4_T6_Tables.Entry entry;
                            if (a1b1 == -3) {
                                entry = T4_T6_Tables.VL3;
                            } else if (a1b1 == -2) {
                                entry = T4_T6_Tables.VL2;
                            } else if (a1b1 == -1) {
                                entry = T4_T6_Tables.VL1;
                            } else if (a1b1 == 0) {
                                entry = T4_T6_Tables.V0;
                            } else if (a1b1 == 1) {
                                entry = T4_T6_Tables.VR1;
                            } else if (a1b1 == 2) {
                                entry = T4_T6_Tables.VR2;
                            } else {
                                entry = T4_T6_Tables.VR3;
                            }
                            entry.writeBits(outputStream);
                            codingA0Color = 1 - codingA0Color;
                            a0 = a1;
                        } else {
                            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);
                            a0 = a2;
                        }
                    }
                    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/common/itu_t4/T4AndT6Compression.java 403
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java 616
                if (tagBit == 0) {
                    // 2D
                    int codingA0Color = WHITE;
                    int referenceA0Color = WHITE;
                    int b1 = nextChangingElement(referenceLine,
                            referenceA0Color, 0);
                    int b2 = nextChangingElement(referenceLine,
                            1 - referenceA0Color, b1 + 1);
                    for (int a0 = 0; a0 < width;) {
                        int a1, a2;
                        entry = (T4_T6_Tables.Entry) controlCodes
                                .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 ImageReadException(
File Line
org/apache/commons/imaging/formats/pnm/PgmWriter.java 37
org/apache/commons/imaging/formats/pnm/PpmWriter.java 37
        os.write(RAWBITS ? 0x35 : 0x32);
        os.write(PNM_SEPARATOR);

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

        os.write(("" + width).getBytes("US-ASCII"));
        os.write(PNM_SEPARATOR);

        os.write(("" + height).getBytes("US-ASCII"));
        os.write(PNM_SEPARATOR);

        os.write(("" + 255).getBytes("US-ASCII")); // max component value
        os.write(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/formats/icns/IcnsImageParser.java 86
org/apache/commons/imaging/formats/icns/IcnsImageParser.java 118
    public ImageInfo getImageInfo(final ByteSource byteSource, Map<String,Object> params)
            throws ImageReadException, IOException {
        // make copy of params; we'll clear keys as we consume them.
        params = (params == null) ? new HashMap<String,Object>() : new HashMap<String,Object>(params);

        ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE, false);

        if (params.containsKey(PARAM_KEY_VERBOSE)) {
            params.remove(PARAM_KEY_VERBOSE);
        }

        if (params.size() > 0) {
            final Object firstKey = params.keySet().iterator().next();
            throw new ImageReadException("Unknown parameter: " + firstKey);
        }

        final IcnsContents contents = readImage(byteSource);
        final List<BufferedImage> images = IcnsDecoder
                .decodeAllImages(contents.icnsElements);
        if (images.isEmpty()) {
            throw new ImageReadException("No icons in ICNS file");
        }
        final BufferedImage image0 = images.get(0);
        return new ImageInfo("Icns", 32, new ArrayList<String>(),
File Line
org/apache/commons/imaging/formats/pcx/PcxWriter.java 215
org/apache/commons/imaging/formats/pcx/PcxWriter.java 357
    private void write24BppPCX(final BufferedImage src, final BinaryOutputStream bos)
            throws ImageWriteException, IOException {
        final int bytesPerLine = src.getWidth() % 2 == 0 ? src.getWidth() : src
                .getWidth() + 1;

        // PCX header
        bos.write(10); // manufacturer
        bos.write(5); // version
        bos.write(encoding); // encoding
        bos.write(8); // bits per pixel
        bos.write2Bytes(0); // xMin
        bos.write2Bytes(0); // yMin
        bos.write2Bytes(src.getWidth() - 1); // xMax
        bos.write2Bytes(src.getHeight() - 1); // yMax
        bos.write2Bytes((short) Math.round(pixelDensity
                .horizontalDensityInches())); // hDpi
        bos.write2Bytes((short) Math.round(pixelDensity.verticalDensityInches())); // vDpi
        bos.write(new byte[48]); // 16 color palette
        bos.write(0); // reserved
        bos.write(3); // planes
File Line
org/apache/commons/imaging/color/ColorConversions.java 132
org/apache/commons/imaging/color/ColorConversions.java 590
        double var_R = var_X * 3.2406 + var_Y * -1.5372 + var_Z * -0.4986;
        double var_G = var_X * -0.9689 + var_Y * 1.8758 + var_Z * 0.0415;
        double var_B = var_X * 0.0557 + var_Y * -0.2040 + var_Z * 1.0570;

        if (var_R > 0.0031308) {
            var_R = 1.055 * Math.pow(var_R, (1 / 2.4)) - 0.055;
        } else {
            var_R = 12.92 * var_R;
        }
        if (var_G > 0.0031308) {
            var_G = 1.055 * Math.pow(var_G, (1 / 2.4)) - 0.055;
        } else {
            var_G = 12.92 * var_G;
        }
        if (var_B > 0.0031308) {
            var_B = 1.055 * Math.pow(var_B, (1 / 2.4)) - 0.055;
        } else {
            var_B = 12.92 * var_B;
        }
File Line
org/apache/commons/imaging/formats/dcx/DcxImageParser.java 74
org/apache/commons/imaging/formats/ico/IcoImageParser.java 76
                ImageFormat.IMAGE_FORMAT_DCX, //
        };
    }

    @Override
    public boolean embedICCProfile(final File src, final File dst, final byte profile[]) {
        return false;
    }

    @Override
    public IImageMetadata getMetadata(final ByteSource byteSource, final Map<String,Object> params)
            throws ImageReadException, IOException {
        return null;
    }

    @Override
    public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String,Object> params)
            throws ImageReadException, IOException {
        return null;
    }

    @Override
    public Dimension getImageSize(final ByteSource byteSource, final Map<String,Object> params)
            throws ImageReadException, IOException {
        return null;
    }

    @Override
    public byte[] getICCProfileBytes(final ByteSource byteSource, final Map<String,Object> params)
            throws ImageReadException, IOException {
        return null;
    }

    private static class DcxHeader {
File Line
org/apache/commons/imaging/color/ColorConversions.java 332
org/apache/commons/imaging/color/ColorConversions.java 445
            final double del_R = (((var_Max - var_R) / 6) + (del_Max / 2)) / del_Max;
            final double del_G = (((var_Max - var_G) / 6) + (del_Max / 2)) / del_Max;
            final double del_B = (((var_Max - var_B) / 6) + (del_Max / 2)) / del_Max;

            if (maxIsR) {
                H = del_B - del_G;
            } else if (maxIsG) {
                H = (1 / 3.0) + del_R - del_B;
            } else {
                H = (2 / 3.0) + del_G - del_R;
            }

            // 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/xbm/XbmImageParser.java 308
org/apache/commons/imaging/formats/xpm/XpmImageParser.java 614
        return readXbmImage(result.xbmHeader, result.cParser);
    }

    private 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 String toPrettyHex(final int value) {
File Line
org/apache/commons/imaging/formats/pcx/PcxWriter.java 267
org/apache/commons/imaging/formats/pcx/PcxWriter.java 366
        bos.write(1); // bits per pixel
        bos.write2Bytes(0); // xMin
        bos.write2Bytes(0); // yMin
        bos.write2Bytes(src.getWidth() - 1); // xMax
        bos.write2Bytes(src.getHeight() - 1); // yMax
        bos.write2Bytes((short) Math.round(pixelDensity
                .horizontalDensityInches())); // hDpi
        bos.write2Bytes((short) Math.round(pixelDensity.verticalDensityInches())); // vDpi
        bos.write(new byte[48]); // 16 color palette
        bos.write(0); // reserved
        bos.write(1); // planes
        bos.write2Bytes(bytesPerLine); // bytes per line
        bos.write2Bytes(1); // palette info
        bos.write2Bytes(0); // hScreenSize
        bos.write2Bytes(0); // vScreenSize
        bos.write(new byte[54]);

        final byte[] row = new byte[bytesPerLine];
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 360
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 383
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 478
    public short[] getFieldValue(final TagInfoShort tag, final boolean mustExist)
            throws ImageReadException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" is missing");
            } else {
                return null;
            }
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" has incorrect type " + field.getFieldType().getName());
            } else {
                return null;
            }
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public int[] getFieldValue(final TagInfoLong tag, final boolean mustExist)
File Line
org/apache/commons/imaging/palette/ColorSpaceSubset.java 95
org/apache/commons/imaging/palette/ColorSpaceSubset.java 112
        System.out.println("\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 184
org/apache/commons/imaging/formats/pcx/PcxWriter.java 267
org/apache/commons/imaging/formats/pcx/PcxWriter.java 366
        bos.write(32); // bits per pixel
        bos.write2Bytes(0); // xMin
        bos.write2Bytes(0); // yMin
        bos.write2Bytes(src.getWidth() - 1); // xMax
        bos.write2Bytes(src.getHeight() - 1); // yMax
        bos.write2Bytes((short) Math.round(pixelDensity
                .horizontalDensityInches())); // hDpi
        bos.write2Bytes((short) Math.round(pixelDensity.verticalDensityInches())); // vDpi
        bos.write(new byte[48]); // 16 color palette
        bos.write(0); // reserved
        bos.write(1); // planes
        bos.write2Bytes(bytesPerLine); // bytes per line
        bos.write2Bytes(1); // palette info
        bos.write2Bytes(0); // hScreenSize
        bos.write2Bytes(0); // vScreenSize
        bos.write(new byte[54]);

        final int rgbs[] = new int[src.getWidth()];
File Line
org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java 41
org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java 39
        final String[] strings = new String[nullCount];
        int stringsAdded = 0;
        strings[0] = ""; // if we have a 0 length string
        int nextStringPos = 0;
        // According to the Exiftool FAQ, 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) {
                try {
                    final String string = new String(bytes, nextStringPos, i
                            - nextStringPos, "UTF-8");
                    strings[stringsAdded++] = string;
                } catch (final UnsupportedEncodingException unsupportedEncoding) {
                }
                nextStringPos = i + 1;
            }
        }
        if (nextStringPos < bytes.length) {
            // Buggy file, string wasn't null terminated
            try {
                final String string = new String(bytes, nextStringPos, bytes.length
                        - nextStringPos, "UTF-8");
                strings[stringsAdded++] = string;
            } catch (final UnsupportedEncodingException unsupportedEncoding) {
            }
        }
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 337
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 360
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 383
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 433
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 478
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 501
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 524
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 547
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 570
    public String[] getFieldValue(final TagInfoAscii tag, final boolean mustExist)
            throws ImageReadException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" is missing");
            } else {
                return null;
            }
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" has incorrect type " + field.getFieldType().getName());
            } else {
                return null;
            }
        }
        final byte[] bytes = field.getByteArrayValue();
        return tag.getValue(field.getByteOrder(), bytes);
    }

    public short[] getFieldValue(final TagInfoShort tag, final boolean mustExist)
File Line
org/apache/commons/imaging/util/Debug.java 687
org/apache/commons/imaging/util/Debug.java 715
    public static String getDebug(final String prefix, final Dimension r) {
        String s_ar1 = "null";
        String s_ar2 = "null";

        if (r != null) {
            final double aspect_ratio = ((double) r.width) / ((double) r.height);
            final double aspect_ratio2 = 1.0 / aspect_ratio;

            s_ar1 = "" + aspect_ratio;
            s_ar2 = "" + aspect_ratio2;

            if (s_ar1.length() > 7) {
                s_ar1 = s_ar1.substring(0, 7);
            }
            if (s_ar2.length() > 7) {
                s_ar2 = s_ar2.substring(0, 7);
            }
        }

        return (prefix + ": "
                + ((r == null) ? "null" : (r.width + "x" + r.height))
File Line
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java 396
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java 472
    public boolean hasExifSegment(final ByteSource byteSource)
            throws ImageReadException, IOException {
        final boolean result[] = { false, };

        final JpegUtils.Visitor visitor = new JpegUtils.Visitor() {
            // return false to exit before reading image data.
            public boolean beginSOS() {
                return false;
            }

            public void visitSOS(final int marker, final byte markerBytes[],
                    final byte imageData[]) {
            }

            // return false to exit traversal.
            public boolean visitSegment(final int marker, final byte markerBytes[],
                    final int markerLength, final byte markerLengthBytes[],
                    final byte segmentData[]) throws ImageReadException, IOException {
                if (marker == 0xffd9) {
                    return false;
                }

                if (marker == JPEG_APP1_Marker) {
                    if (startsWith(segmentData, EXIF_IDENTIFIER_CODE)) {
File Line
org/apache/commons/imaging/formats/bmp/BmpImageParser.java 527
org/apache/commons/imaging/formats/bmp/BmpImageParser.java 593
    public Dimension getImageSize(final ByteSource byteSource, Map<String,Object> params)
            throws ImageReadException, IOException {
        // make copy of params; we'll clear keys as we consume them.
        params = (params == null) ? new HashMap<String,Object>() : new HashMap<String,Object>(params);

        final boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
                false);

        if (params.containsKey(PARAM_KEY_VERBOSE)) {
            params.remove(PARAM_KEY_VERBOSE);
        }

        if (params.size() > 0) {
            final Object firstKey = params.keySet().iterator().next();
            throw new ImageReadException("Unknown parameter: " + firstKey);
        }
File Line
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java 396
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java 434
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java 472
    public boolean hasExifSegment(final ByteSource byteSource)
            throws ImageReadException, IOException {
        final boolean result[] = { false, };

        final JpegUtils.Visitor visitor = new JpegUtils.Visitor() {
            // return false to exit before reading image data.
            public boolean beginSOS() {
                return false;
            }

            public void visitSOS(final int marker, final byte markerBytes[],
                    final byte imageData[]) {
            }

            // return false to exit traversal.
            public boolean visitSegment(final int marker, final byte markerBytes[],
                    final int markerLength, final byte markerLengthBytes[],
                    final byte segmentData[]) throws ImageReadException, IOException {
                if (marker == 0xffd9) {
                    return false;
                }

                if (marker == JPEG_APP1_Marker) {
File Line
org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java 237
org/apache/commons/imaging/formats/xpm/XpmImageParser.java 655
        }
    }

    @Override
    public void writeImage(final BufferedImage src, final OutputStream os, Map<String,Object> params)
            throws ImageWriteException, IOException {
        // make copy of params; we'll clear keys as we consume them.
        params = (params == null) ? new HashMap<String,Object>() : new HashMap<String,Object>(params);

        // clear format key.
        if (params.containsKey(PARAM_KEY_FORMAT)) {
            params.remove(PARAM_KEY_FORMAT);
        }

        if (params.size() > 0) {
            final Object firstKey = params.keySet().iterator().next();
            throw new ImageWriteException("Unknown parameter: " + firstKey);
        }
File Line
org/apache/commons/imaging/formats/xbm/XbmImageParser.java 334
org/apache/commons/imaging/formats/xpm/XpmImageParser.java 656
    }

    @Override
    public void writeImage(final BufferedImage src, final OutputStream os, Map<String,Object> params)
            throws ImageWriteException, IOException {
        // make copy of params; we'll clear keys as we consume them.
        params = (params == null) ? new HashMap<String,Object>() : new HashMap<String,Object>(params);

        // clear format key.
        if (params.containsKey(PARAM_KEY_FORMAT)) {
            params.remove(PARAM_KEY_FORMAT);
        }

        if (params.size() > 0) {
            final Object firstKey = params.keySet().iterator().next();
            throw new ImageWriteException("Unknown parameter: " + firstKey);
        }

        final String name = randomName();
File Line
org/apache/commons/imaging/formats/icns/IcnsImageParser.java 297
org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java 238
org/apache/commons/imaging/formats/xbm/XbmImageParser.java 334
org/apache/commons/imaging/formats/xpm/XpmImageParser.java 656
    }

    @Override
    public void writeImage(final BufferedImage src, final OutputStream os, Map<String,Object> params)
            throws ImageWriteException, IOException {
        // make copy of params; we'll clear keys as we consume them.
        params = (params == null) ? new HashMap<String,Object>() : new HashMap<String,Object>(params);

        // clear format key.
        if (params.containsKey(PARAM_KEY_FORMAT)) {
            params.remove(PARAM_KEY_FORMAT);
        }

        if (params.size() > 0) {
            final Object firstKey = params.keySet().iterator().next();
            throw new ImageWriteException("Unknown parameter: " + firstKey);
        }
File Line
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java 476
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java 525
        final JpegUtils.Visitor visitor = new JpegUtils.Visitor() {
            // return false to exit before reading image data.
            public boolean beginSOS() {
                return false;
            }

            public void visitSOS(final int marker, final byte markerBytes[],
                    final byte imageData[]) {
            }

            // return false to exit traversal.
            public boolean visitSegment(final int marker, final byte markerBytes[],
                    final int markerLength, final byte markerLengthBytes[],
                    final byte segmentData[]) throws ImageReadException, IOException {
                if (marker == 0xffd9) {
                    return false;
                }

                if (marker == JPEG_APP1_Marker) {
                    if (new JpegXmpParser().isXmpJpegSegment(segmentData)) {
                        result[0] = true;
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 337
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 360
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 383
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 406
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 433
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 478
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 501
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 524
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 547
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 570
    public String[] getFieldValue(final TagInfoAscii tag, final boolean mustExist)
            throws ImageReadException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" is missing");
            } else {
                return null;
            }
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" has incorrect type " + field.getFieldType().getName());
            } else {
                return null;
            }
        }
        final byte[] bytes = field.getByteArrayValue();
File Line
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java 450
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java 661
                                                + 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;
                    }
                } else {
File Line
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 315
org/apache/commons/imaging/formats/tiff/TiffDirectory.java 456
    public byte[] getFieldValue(final TagInfoByte tag, final boolean mustExist)
            throws ImageReadException {
        final TiffField field = findField(tag);
        if (field == null) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" is missing");
            } else {
                return null;
            }
        }
        if (!tag.dataTypes.contains(field.getFieldType())) {
            if (mustExist) {
                throw new ImageReadException("Required field \"" + tag.name
                        + "\" has incorrect type " + field.getFieldType().getName());
            } else {
                return null;
            }
        }
        return field.getByteArrayValue();
    }

    public String[] getFieldValue(final TagInfoAscii tag, final boolean mustExist)
File Line
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java 208
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java 263
        for (int strip = 0; strip < imageData.strips.length; strip++) {
            final long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
            final long rowsRemaining = height - (strip * rowsPerStripLong);
            final long rowsInThisStrip = Math.min(rowsRemaining, rowsPerStripLong);
            final long bytesPerRow = (bitsPerPixel * width + 7) / 8;
            final long bytesPerStrip = rowsInThisStrip * bytesPerRow;
            final long pixelsPerStrip = rowsInThisStrip * width;

            final byte compressed[] = imageData.strips[strip].getData();

            final byte decompressed[] = decompress(compressed, compression,
                    (int) bytesPerStrip, width, (int) rowsInThisStrip);

            interpretStrip(