From commits-return-13878-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Thu Sep 3 13:51:11 2020 Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with ESMTP id 8DC431AEB5 for ; Thu, 3 Sep 2020 13:51:10 +0000 (UTC) Received: from mail.apache.org (localhost [127.0.0.1]) by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id 42F2C121B52 for ; Thu, 3 Sep 2020 13:51:10 +0000 (UTC) Received: (qmail 78987 invoked by uid 500); 3 Sep 2020 13:51:10 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 78948 invoked by uid 500); 3 Sep 2020 13:51:10 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 78864 invoked by uid 99); 3 Sep 2020 13:51:09 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2020 13:51:09 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B88E580895; Thu, 3 Sep 2020 13:51:09 +0000 (UTC) Date: Thu, 03 Sep 2020 13:51:11 +0000 To: "commits@sis.apache.org" Subject: [sis] 02/04: Make the `bounds` argument optional, with default to the full image. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: desruisseaux@apache.org In-Reply-To: <159914106906.5449.18400369465218973990@gitbox.apache.org> References: <159914106906.5449.18400369465218973990@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: sis X-Git-Refname: refs/heads/geoapi-4.0 X-Git-Reftype: branch X-Git-Rev: 65f809b78a86dc170250afb2b7d842d2f8b18fa4 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20200903135109.B88E580895@gitbox.apache.org> 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 65f809b78a86dc170250afb2b7d842d2f8b18fa4 Author: Martin Desruisseaux AuthorDate: Thu Sep 3 11:54:47 2020 +0200 Make the `bounds` argument optional, with default to the full image. --- .../src/main/java/org/apache/sis/image/ImageCombiner.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/ImageCombiner.java b/core/sis-feature/src/main/java/org/apache/sis/image/ImageCombiner.java index 8a1f5d9..533d3ac 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/image/ImageCombiner.java +++ b/core/sis-feature/src/main/java/org/apache/sis/image/ImageCombiner.java @@ -29,6 +29,7 @@ import org.apache.sis.internal.coverage.j2d.ImageLayout; import org.apache.sis.internal.coverage.j2d.ImageUtilities; import org.apache.sis.internal.coverage.j2d.TileOpExecutor; import org.apache.sis.internal.util.Numerics; +import org.apache.sis.internal.jdk9.JDK9; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.measure.Units; @@ -211,22 +212,27 @@ public class ImageCombiner implements Consumer { * Destination pixels that can not be mapped to source pixels are left unchanged. * * @param source the image to be resampled. - * @param bounds domain of pixel coordinates in the destination image. + * @param bounds domain of pixel coordinates in the destination image, or {@code null} for the whole image. * @param toSource conversion of pixel coordinates from destination image to {@code source} image. * * @see ImageProcessor#resample(RenderedImage, Rectangle, MathTransform) */ public void resample(final RenderedImage source, Rectangle bounds, final MathTransform toSource) { + ArgumentChecks.ensureNonNull("source", source); + ArgumentChecks.ensureNonNull("toSource", toSource); + if (bounds == null) { + bounds = ImageUtilities.getBounds(destination); + } final int tileWidth = destination.getTileWidth(); final int tileHeight = destination.getTileHeight(); final long tileGridXOffset = destination.getTileGridXOffset(); final long tileGridYOffset = destination.getTileGridYOffset(); final int minTileX = Math.toIntExact(Math.floorDiv((bounds.x - tileGridXOffset), tileWidth)); final int minTileY = Math.toIntExact(Math.floorDiv((bounds.y - tileGridYOffset), tileHeight)); - final int minX = Math.toIntExact((minTileX * (long) tileWidth) + tileGridXOffset); - final int minY = Math.toIntExact((minTileY * (long) tileHeight) + tileGridYOffset); + final int minX = Math.toIntExact(JDK9.multiplyFull(minTileX, tileWidth) + tileGridXOffset); + final int minY = Math.toIntExact(JDK9.multiplyFull(minTileY, tileHeight) + tileGridYOffset); /* - * Exand the target bounds until it contains an integer number of tiles, computed using the size + * Expand the target bounds until it contains an integer number of tiles, computed using the size * of destination tiles. We have to do that because the resample operation below is not free to * choose a tile size suiting the given bounds. */