CPD Results
The following document contains the results of PMD's CPD 6.42.0.
Duplications
File |
Line |
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java |
301 |
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java |
479 |
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 {
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/common/itu_t4/T4AndT6Compression.java |
397 |
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java |
551 |
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 ImageReadException("Invalid/unknown T.4 control code " + entry.bitString); |
File |
Line |
org/apache/commons/imaging/formats/pnm/PgmWriter.java |
40 |
org/apache/commons/imaging/formats/pnm/PpmWriter.java |
40 |
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/formats/tiff/datareaders/ImageDataReader.java |
700 |
org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java |
821 |
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/color/ColorCieLab.java |
105 |
org/apache/commons/imaging/color/ColorHunterLab.java |
104 |
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);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
} |
File |
Line |
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java |
316 |
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java |
368 |
float[] rasterDataFloat = new float[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( |
File |
Line |
org/apache/commons/imaging/color/ColorConversions.java |
313 |
org/apache/commons/imaging/color/ColorConversions.java |
426 |
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/tiff/TiffRasterDataFloat.java |
143 |
org/apache/commons/imaging/formats/tiff/TiffRasterDataInt.java |
141 |
data[index] = value;
}
/**
* 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.NaN.
*/
@Override
public float getValue(final int x, final int y) {
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.NaN.
*/
@Override
public float getValue(final int x, final int y, int i) {
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) {
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, int i, final int value) {
int index = checkCoordinatesAndComputeIndex(x, y, 0); |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
369 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
547 |
public short getFieldValue(final TagInfoShort tag)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
}
if (!tag.dataTypes.contains(field.getFieldType())) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
if (field.getCount() != 1) {
throw new ImageReadException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
}
final byte[] bytes = field.getByteArrayValue();
return tag.getValue(field.getByteOrder(), bytes);
}
public short[] getFieldValue(final TagInfoShorts tag, final boolean mustExist) |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
408 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
586 |
public int getFieldValue(final TagInfoLong tag)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
}
if (!tag.dataTypes.contains(field.getFieldType())) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
if (field.getCount() != 1) {
throw new ImageReadException("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) |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
471 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
625 |
public RationalNumber getFieldValue(final TagInfoRational tag)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
}
if (!tag.dataTypes.contains(field.getFieldType())) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
if (field.getCount() != 1) {
throw new ImageReadException("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) |
File |
Line |
org/apache/commons/imaging/palette/LongestAxisMedianCut.java |
62 |
org/apache/commons/imaging/palette/MostPopulatedBoxesMedianCut.java |
52 |
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 |
542 |
org/apache/commons/imaging/formats/tiff/TiffImageParser.java |
845 |
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 ImageReadException("negative or zero subimage width");
}
if (subImage.height <= 0) {
throw new ImageReadException("negative or zero subimage height");
}
if (subImage.x < 0 || subImage.x >= width) {
throw new ImageReadException("subimage x is outside raster");
}
if (subImage.x + subImage.width > width) {
throw new ImageReadException("subimage (x+width) is outside raster");
}
if (subImage.y < 0 || subImage.y >= height) {
throw new ImageReadException("subimage y is outside raster");
}
if (subImage.y + subImage.height > height) {
throw new ImageReadException("subimage (y+height) is outside raster");
} |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
369 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
408 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
471 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
547 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
586 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
625 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
663 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
702 |
public short getFieldValue(final TagInfoShort tag)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
}
if (!tag.dataTypes.contains(field.getFieldType())) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
if (field.getCount() != 1) {
throw new ImageReadException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
}
final byte[] bytes = field.getByteArrayValue();
return tag.getValue(field.getByteOrder(), bytes);
}
public short[] getFieldValue(final TagInfoShorts tag, final boolean mustExist) |
File |
Line |
org/apache/commons/imaging/palette/ColorSpaceSubset.java |
101 |
org/apache/commons/imaging/palette/ColorSpaceSubset.java |
117 |
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/xbm/XbmImageParser.java |
321 |
org/apache/commons/imaging/formats/xpm/XpmImageParser.java |
609 |
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/formats/pcx/PcxWriter.java |
217 |
org/apache/commons/imaging/formats/pcx/PcxWriter.java |
225 |
} 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/TiffDirectory.java |
387 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
565 |
public short[] getFieldValue(final TagInfoShorts 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");
}
return null;
}
if (!tag.dataTypes.contains(field.getFieldType())) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
return null;
}
final byte[] bytes = field.getByteArrayValue();
return tag.getValue(field.getByteOrder(), bytes);
}
public int getFieldValue(final TagInfoLong tag) |
File |
Line |
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java |
399 |
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java |
483 |
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.
@Override
public boolean beginSOS() {
return false;
}
@Override
public void visitSOS(final int marker, final byte[] markerBytes,
final byte[] imageData) {
// don't need image data
}
// return false to exit traversal.
@Override
public boolean visitSegment(final int marker, final byte[] markerBytes,
final int markerLength, final byte[] markerLengthBytes,
final byte[] segmentData) {
if (marker == 0xffd9) {
return false;
}
if (marker == JpegConstants.JPEG_APP1_MARKER) {
if (startsWith(segmentData, JpegConstants.EXIF_IDENTIFIER_CODE)) { |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
311 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
510 |
public byte getFieldValue(final TagInfoByte tag)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
}
if (!tag.dataTypes.contains(field.getFieldType())) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
if (field.getCount() != 1) {
throw new ImageReadException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
}
return field.getByteArrayValue()[0];
}
public byte[] getFieldValue(final TagInfoBytes tag, final boolean mustExist) |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
387 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
426 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
565 |
public short[] getFieldValue(final TagInfoShorts 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");
}
return null;
}
if (!tag.dataTypes.contains(field.getFieldType())) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
return null;
}
final byte[] bytes = field.getByteArrayValue();
return tag.getValue(field.getByteOrder(), bytes);
}
public int getFieldValue(final TagInfoLong tag) |
File |
Line |
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java |
376 |
org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java |
429 |
float[] rasterDataFloat = new float[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( |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
348 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
387 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
426 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
489 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
565 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
604 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
642 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
681 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
720 |
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");
}
return null;
}
if (!tag.dataTypes.contains(field.getFieldType())) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
return null;
}
final byte[] bytes = field.getByteArrayValue();
return tag.getValue(field.getByteOrder(), bytes);
}
public short getFieldValue(final TagInfoShort tag) |
File |
Line |
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java |
399 |
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java |
441 |
org/apache/commons/imaging/formats/jpeg/JpegImageParser.java |
483 |
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.
@Override
public boolean beginSOS() {
return false;
}
@Override
public void visitSOS(final int marker, final byte[] markerBytes,
final byte[] imageData) {
// don't need image data
}
// return false to exit traversal.
@Override
public boolean visitSegment(final int marker, final byte[] markerBytes,
final int markerLength, final byte[] markerLengthBytes,
final byte[] segmentData) {
if (marker == 0xffd9) {
return false;
}
if (marker == JpegConstants.JPEG_APP1_MARKER) { |
File |
Line |
org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java |
116 |
org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java |
129 |
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/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) {
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/common/itu_t4/T4AndT6Compression.java |
426 |
org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java |
580 |
throw new ImageReadException("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;
}
} else { |
File |
Line |
org/apache/commons/imaging/color/ColorCmy.java |
141 |
org/apache/commons/imaging/color/ColorCmyk.java |
154 |
if (Double.compare(colorCmy.Y, Y) != 0) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(C);
result = (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(M);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(Y);
result = 31 * result + (int) (temp ^ (temp >>> 32)); |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
348 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
387 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
426 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
447 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
489 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
565 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
604 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
642 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
681 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
720 |
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");
}
return null;
}
if (!tag.dataTypes.contains(field.getFieldType())) {
if (mustExist) {
throw new ImageReadException("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 |
311 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
369 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
408 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
471 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
510 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
547 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
586 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
625 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
663 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
702 |
public byte getFieldValue(final TagInfoByte tag)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
}
if (!tag.dataTypes.contains(field.getFieldType())) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
if (field.getCount() != 1) {
throw new ImageReadException("Field \"" + tag.name + "\" has wrong count " + field.getCount());
} |
File |
Line |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
328 |
org/apache/commons/imaging/formats/tiff/TiffDirectory.java |
527 |
public byte[] getFieldValue(final TagInfoBytes 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");
}
return null;
}
if (!tag.dataTypes.contains(field.getFieldType())) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
}
return null;
}
return field.getByteArrayValue();
}
public String[] getFieldValue(final TagInfoAscii tag, final boolean mustExist) |
|