From 6bc5bf18c4017746a291e98c18757016f1980022 Mon Sep 17 00:00:00 2001 From: Michael Hochmuth Date: Fri, 23 Feb 2024 10:09:37 +0000 Subject: [PATCH] TIFF plugin: accept byte-type for fields in getAsInts --- .../it/geosolutions/imageio/plugins/tiff/TIFFField.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/tiff/src/main/java/it/geosolutions/imageio/plugins/tiff/TIFFField.java b/plugin/tiff/src/main/java/it/geosolutions/imageio/plugins/tiff/TIFFField.java index da674d0cc..dcadbb83d 100644 --- a/plugin/tiff/src/main/java/it/geosolutions/imageio/plugins/tiff/TIFFField.java +++ b/plugin/tiff/src/main/java/it/geosolutions/imageio/plugins/tiff/TIFFField.java @@ -868,9 +868,16 @@ public int[] getAsInts() { idata[i] = (int)sdata[i]; } return idata; + } else if (data instanceof byte[]) { + byte[] bdata = (byte[])data; + int[] idata = new int[bdata.length]; + for (int i = 0; i < bdata.length; i++) { + idata[i] = (int)(bdata[i] & 0xff); + } + return idata; } else { throw new ClassCastException( - "Data not char[], short[], or int[]!"); + "Data not char[], short[], int[] or byte[]!"); } }