gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341290307
##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##########
@@ -455,27 +473,47 @@ private TiffHeader readTiffHeader(final ByteSource
byteSource) throws ImagingExc
}
}
- private TiffHeader readTiffHeader(final InputStream is) throws
ImagingException, IOException {
- final int byteOrder1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF
File");
- final int byteOrder2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF
File");
- if (byteOrder1 != byteOrder2) {
- throw new ImagingException("Byte Order bytes don't match (" +
byteOrder1 + ", " + byteOrder2 + ").");
- }
-
- final ByteOrder byteOrder = getTiffByteOrder(byteOrder1);
- setByteOrder(byteOrder);
-
- final int tiffVersion = read2Bytes("tiffVersion", is, "Not a Valid
TIFF File", getByteOrder());
- if (tiffVersion != 42) {
- throw new ImagingException("Unknown TIFF Version: " + tiffVersion);
- }
+ private TiffHeader readTiffHeader(final InputStream is) throws
ImagingException, IOException {
Review Comment:
done
##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -288,6 +296,55 @@ public int getIntValueOrArraySum() throws ImagingException
{
// return -1;
}
+ public long[] getLongArrayValue() throws ImagingException {
+ final Object o = getValue();
+ // if (o == null)
+ // return null;
+
+ if (o instanceof Number) {
+ return new long[] { ((Number) o).longValue() };
+ }
+ if (o instanceof Number[]) {
+ final Number[] numbers = (Number[]) o;
+ final long[] result = Allocator.longArray(numbers.length);
+ Arrays.setAll(result, i -> numbers[i].longValue());
+ return result;
+ }
+ if (o instanceof short[]) {
+ final short[] numbers = (short[]) o;
+ final long[] result = Allocator.longArray(numbers.length);
+ Arrays.setAll(result, i -> 0xffff & numbers[i]);
+ return result;
+ }
+ if (o instanceof int[]) {
+ final int[] numbers = (int[]) o;
+ final long[]result = Allocator.longArray(numbers.length);
+ Arrays.setAll(result, i -> 0xFFFFffffL & numbers[i]);
+ return result;
+ }
+ if (o instanceof long[]){
+ final long[] numbers = (long[]) o;
+ return Arrays.copyOf(numbers, numbers.length);
+ }
+
+ throw new ImagingException("Unknown value: " + o + " for: "
+ + getTagInfo().getDescription());
+ // return null;
+ }
+
+ public long getLongValue() throws ImagingException {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]