mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
#195 ArrayIndexOutOfBoundsException for ResampleOp in certain cases
This commit is contained in:
parent
f21bc2089a
commit
6ce58dd682
@ -1465,7 +1465,7 @@ public class ResampleOp implements BufferedImageOp/* TODO: RasterOp */ {
|
||||
|
||||
for (int i = 0; i < dstHeight; i++) {
|
||||
//contribY[i].n = 0;
|
||||
contribY[i].p = new Contributor[(int) (width * 2.0 + 1)];
|
||||
contribY[i].p = new Contributor[(int) (width * 2.0 + 1 + 0.5)];
|
||||
|
||||
double center = (double) i / yscale;
|
||||
int left = (int) Math.ceil(center - width);
|
||||
@ -1516,7 +1516,7 @@ public class ResampleOp implements BufferedImageOp/* TODO: RasterOp */ {
|
||||
else {
|
||||
for (int i = 0; i < dstHeight; ++i) {
|
||||
//contribY[i].n = 0;
|
||||
contribY[i].p = new Contributor[(int) (fwidth * 2 + 1)];
|
||||
contribY[i].p = new Contributor[(int) (fwidth * 2 + 1 + 0.5)];
|
||||
|
||||
double center = (double) i / yscale;
|
||||
double left = Math.ceil(center - fwidth);
|
||||
|
@ -69,7 +69,7 @@ public class ResampleOpTestCase {
|
||||
}
|
||||
|
||||
private void assertResampleBufferedImageTypes(final int pFilterType) {
|
||||
List<String> exceptions = new ArrayList<String>();
|
||||
List<String> exceptions = new ArrayList<>();
|
||||
|
||||
// Test all image types in BufferedImage
|
||||
for (int type = BufferedImage.TYPE_INT_ARGB; type <= BufferedImage.TYPE_BYTE_INDEXED; type++) {
|
||||
@ -304,6 +304,18 @@ public class ResampleOpTestCase {
|
||||
assertResampleBufferedImageTypes(ResampleOp.FILTER_LANCZOS);
|
||||
}
|
||||
|
||||
// https://github.com/haraldk/TwelveMonkeys/issues/195
|
||||
@Test
|
||||
public void testAIOOBE() {
|
||||
BufferedImage myImage = new BufferedImage(100, 354, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
for (int i = 19; i > 0; i--) {
|
||||
ResampleOp resampler = new ResampleOp(100, 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