Skip to content

Commit 1a46401

Browse files
committed
Remove some checks now that width and height can be 0, and coordinates negative
1 parent d4a3c52 commit 1a46401

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/edu/cmu/cs/openslide/OpenSlide.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,8 @@ public void paintRegionARGB(int dest[], long x, long y, int layer, int w,
205205
+ dest.length + ") is less than w * h");
206206
}
207207

208-
if (x < 0 || y < 0) {
209-
throw new IllegalArgumentException("x and y must be nonnegative");
210-
}
211-
212-
if (w <= 0 || h <= 0) {
213-
throw new IllegalArgumentException("w and h must be positive");
208+
if (w < 0 || h < 0) {
209+
throw new IllegalArgumentException("w and h must be nonnegative");
214210
}
215211

216212
Lock rl = lock.readLock();
@@ -240,18 +236,6 @@ public void paintRegion(Graphics2D g, int dx, int dy, long sx, long sy,
240236
// compute the difference
241237
double relativeDS = downsample / layerDS;
242238

243-
// translate if sx or sy are negative
244-
if (sx < 0) {
245-
dx -= sx;
246-
w += sx; // shrink w
247-
sx = 0;
248-
}
249-
if (sy < 0) {
250-
dy -= sy;
251-
h += sy; // shrink h
252-
sy = 0;
253-
}
254-
255239
// scale source coordinates into layer coordinates
256240
long baseX = (long) (downsample * sx);
257241
long baseY = (long) (downsample * sy);

0 commit comments

Comments
 (0)