mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-03 19:45:28 -04:00
#195: Fixed AIOOBE related to specific widths
This commit is contained in:
parent
9e5204ddbb
commit
04a4c6e3ae
@ -1336,7 +1336,7 @@ public class ResampleOp implements BufferedImageOp/* TODO: RasterOp */ {
|
||||
}
|
||||
|
||||
//contribX.n = 0;
|
||||
contribX.p = new Contributor[(int) (width * 2.0 + 1.0)];
|
||||
contribX.p = new Contributor[(int) (width * 2.0 + 1.0 + 0.5)];
|
||||
|
||||
center = (double) i / xscale;
|
||||
int left = (int) Math.ceil(center - width);// Note: Assumes width <= .5
|
||||
@ -1387,7 +1387,7 @@ public class ResampleOp implements BufferedImageOp/* TODO: RasterOp */ {
|
||||
else {
|
||||
/* Expanding image */
|
||||
//contribX.n = 0;
|
||||
contribX.p = new Contributor[(int) (fwidth * 2.0 + 1.0)];
|
||||
contribX.p = new Contributor[(int) (fwidth * 2.0 + 1.0 + 0.5)];
|
||||
|
||||
center = (double) i / xscale;
|
||||
int left = (int) Math.ceil(center - fwidth);
|
||||
|
@ -306,7 +306,7 @@ public class ResampleOpTestCase {
|
||||
|
||||
// https://github.com/haraldk/TwelveMonkeys/issues/195
|
||||
@Test
|
||||
public void testAIOOBE() {
|
||||
public void testAIOOBEHeight() {
|
||||
BufferedImage myImage = new BufferedImage(100, 354, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
for (int i = 19; i > 0; i--) {
|
||||
@ -316,6 +316,18 @@ public class ResampleOpTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/haraldk/TwelveMonkeys/issues/195
|
||||
@Test
|
||||
public void testAIOOBEWidth() {
|
||||
BufferedImage myImage = new BufferedImage(2832, 2832, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
for (int i = 145; i > 143; i--) {
|
||||
ResampleOp resampler = new ResampleOp(144, i, ResampleOp.FILTER_LANCZOS);
|
||||
BufferedImage resizedImage = resampler.filter(myImage, null);
|
||||
assertNotNull(resizedImage);
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Not for general unit testing")
|
||||
@Test
|
||||
public void testTime() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user