This is an automated email from the ASF dual-hosted git repository.
jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 97a7d215f4 Avoid a raster copy in gimi MatrixGridResource
97a7d215f4 is described below
commit 97a7d215f44dfe4e08fdacb599f3c4efa0313b47
Author: jsorel <[email protected]>
AuthorDate: Mon Oct 14 11:57:05 2024 +0200
Avoid a raster copy in gimi MatrixGridResource
---
.../sis/storage/gimi/internal/MatrixGridRessource.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git
a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/internal/MatrixGridRessource.java
b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/internal/MatrixGridRessource.java
index 9fe163fe80..72817b3b51 100644
---
a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/internal/MatrixGridRessource.java
+++
b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/internal/MatrixGridRessource.java
@@ -124,8 +124,17 @@ public abstract class MatrixGridRessource extends
TiledGridResource {
long[] tileCoord =
iterator.getTileCoordinatesInResource();
final RenderedImage image = getTileImage(tileCoord);
var s = new Snapshot(iterator);
- Raster raster = (image instanceof BufferedImage) ?
((BufferedImage)image).getRaster() : image.getData();
- raster = raster.createTranslatedChild(s.originX,
s.originY);
+ Raster raster;
+ if (image instanceof BufferedImage) {
+ raster = ((BufferedImage)image).getRaster();
+ } else if (image.getNumXTiles() == 1 &&
image.getNumYTiles() == 1) {
+ raster = image.getTile(0, 0);
+ } else {
+ raster = image.getData();
+ }
+ if (s.originX != 0 || s.originY != 0) {
+ raster = raster.createTranslatedChild(s.originX,
s.originY);
+ }
result[iterator.getTileIndexInResultArray()] = raster;
}
} while (iterator.next());