You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2020/08/21 11:01:36 UTC
[sis] 01/02: Fix a few holes related to the addition of a
`destination` property in `ComputedImage`.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit dc359f5a4c4051607b6feb7a71f42bcb576badfe
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Fri Aug 21 10:02:39 2020 +0200
Fix a few holes related to the addition of a `destination` property in `ComputedImage`.
---
.../java/org/apache/sis/image/ComputedImage.java | 23 ++++++++++++++--------
.../java/org/apache/sis/image/ResampledImage.java | 14 ++++++++-----
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/ComputedImage.java b/core/sis-feature/src/main/java/org/apache/sis/image/ComputedImage.java
index 2309976..36828d8 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/ComputedImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/ComputedImage.java
@@ -300,15 +300,10 @@ public abstract class ComputedImage extends PlanarImage implements Disposable {
}
/**
- * Returns the source at the given index.
- *
- * @param index index of the desired source.
- * @return source at the given index.
- * @throws IndexOutOfBoundsException if the given index is out of bounds.
+ * Returns the destination, or {@code null} if none.
*/
- protected final RenderedImage getSource(final int index) {
- if (sources != null) return sources[index];
- else throw new IndexOutOfBoundsException();
+ final WritableRenderedImage getDestination() {
+ return destination;
}
/**
@@ -320,6 +315,18 @@ public abstract class ComputedImage extends PlanarImage implements Disposable {
}
/**
+ * Returns the source at the given index.
+ *
+ * @param index index of the desired source.
+ * @return source at the given index.
+ * @throws IndexOutOfBoundsException if the given index is out of bounds.
+ */
+ protected final RenderedImage getSource(final int index) {
+ if (sources != null) return sources[index];
+ else throw new IndexOutOfBoundsException();
+ }
+
+ /**
* Returns the immediate sources of image data for this image (may be {@code null}).
* This method returns all sources specified at construction time.
*
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java b/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java
index e8652f9..c3b823a 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/ResampledImage.java
@@ -439,7 +439,9 @@ public class ResampledImage extends ComputedImage {
*/
@Override
public ColorModel getColorModel() {
- return getSource().getColorModel();
+ RenderedImage image = getDestination();
+ if (image == null) image = getSource();
+ return image.getColorModel();
}
/**
@@ -816,10 +818,12 @@ public class ResampledImage extends ComputedImage {
public boolean equals(final Object object) {
if (object != null && object.getClass().equals(getClass())) {
final ResampledImage other = (ResampledImage) object;
- return minX == other.minX &&
- minY == other.minY &&
- width == other.width &&
- height == other.height &&
+ return minX == other.minX &&
+ minY == other.minY &&
+ width == other.width &&
+ height == other.height &&
+ minTileX == other.minTileX &&
+ minTileY == other.minTileY &&
interpolation.equals(other.interpolation) &&
Objects.deepEquals(fillValues, other.fillValues) &&
toSource.equals(other.toSource) &&