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 de57949f78a027057eb8401168991b68613abb58 Author: Martin Desruisseaux <[email protected]> AuthorDate: Tue Nov 9 14:23:38 2021 +0100 Add a convenience method for filling pixel values of a whole image. --- .../sis/internal/coverage/j2d/FillValues.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/FillValues.java b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/FillValues.java index 1533717..a6d8890 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/FillValues.java +++ b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/FillValues.java @@ -22,6 +22,7 @@ import java.lang.reflect.Array; import java.awt.image.DataBuffer; import java.awt.image.SampleModel; import java.awt.image.WritableRaster; +import java.awt.image.WritableRenderedImage; /** @@ -168,6 +169,27 @@ public final class FillValues { } /** + * Fills the given image with the fill value. The image sample model should be the same + * than the sample model specified at construction time of this {@code FillValues} object. + * + * @param image the image to fill. + */ + public void fill(final WritableRenderedImage image) { + int y = image.getMinTileY(); + for (int ny = image.getNumYTiles(); --ny >= 0; y++) { + int x = image.getMinTileX(); + for (int nx = image.getNumXTiles(); --nx >= 0; x++) { + final WritableRaster raster = image.getWritableTile(x, y); + try { + fill(raster); + } finally { + image.releaseWritableTile(x, y); + } + } + } + } + + /** * Compares this object with given object for equality. * * @param obj the other object to compare with this object.
