garydgregory commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1338737448
##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -234,6 +234,14 @@ public int[] getIntArrayValue() throws ImagingException {
final int[] numbers = (int[]) o;
return Arrays.copyOf(numbers, numbers.length);
}
+ if (o instanceof long[]){
Review Comment:
The formatting seems off in the block, missing spaces.
##########
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 {
Review Comment:
We should provide Javadocs on all new public and protected methods IMO.
##########
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:
Formatting seems odd.
##########
src/main/java/org/apache/commons/imaging/common/ByteConversions.java:
##########
@@ -399,6 +399,43 @@ private static int[] toUInt16s(final byte[] bytes, final
int offset, final int l
return result;
}
+ public static long toLong(final byte[] bytes, final ByteOrder byteOrder) {
Review Comment:
Also, it looks like there is an extra space in front of `public`?
##########
src/main/java/org/apache/commons/imaging/common/ByteConversions.java:
##########
@@ -399,6 +399,43 @@ private static int[] toUInt16s(final byte[] bytes, final
int offset, final int l
return result;
}
+ public static long toLong(final byte[] bytes, final ByteOrder byteOrder) {
Review Comment:
We should provide Javadocs on all new public and protected methods IMO.
##########
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:
We should provide Javadocs on all new public and protected methods IMO.
--
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]