Index: java/common/java/awt/image/LookupOp.java =================================================================== --- java/common/java/awt/image/LookupOp.java (revision 448875) +++ java/common/java/awt/image/LookupOp.java (working copy) @@ -126,11 +126,24 @@ public final WritableRaster filter(Raster src, WritableRaster dst) { if (dst == null) { dst = createCompatibleDestRaster(src); - } else if (src.getNumBands() != dst.getNumBands()) { - throw new IllegalArgumentException( - "Source and destinations rasters do not have " + - "the same number of bands" - ); + } else { + if (src.getNumBands() != dst.getNumBands()) { + throw new IllegalArgumentException( + "Source and destination rasters do not have " + + "the same number of bands"); + } + + if (src.getWidth() != dst.getWidth()){ + throw new IllegalArgumentException( + "Source and destination rasters do not have " + + "the same width!"); + } + + if (src.getHeight() != dst.getHeight()){ + throw new IllegalArgumentException( + "Source and destination rasters do not have " + + "the same height!"); + } } if (lut.getNumComponents() != 1 && lut.getNumComponents() != src.getNumBands()) { @@ -184,17 +197,30 @@ if (dst == null) { finalDst = dst; dst = createCompatibleDestImage(src, null); - } else if (!srcCM.equals(dst.getColorModel())) { - // Treat BufferedImage.TYPE_INT_RGB and BufferedImage.TYPE_INT_ARGB as same - if ( - !((src.getType() == BufferedImage.TYPE_INT_RGB || - src.getType() == BufferedImage.TYPE_INT_ARGB) && - (dst.getType() == BufferedImage.TYPE_INT_RGB || - dst.getType() == BufferedImage.TYPE_INT_ARGB)) - ) { - finalDst = dst; - dst = createCompatibleDestImage(src, null); + } else { + if (src.getWidth() != dst.getWidth()){ + throw new IllegalArgumentException( + "Source and destination images do not have " + + "the same width!"); } + + if (src.getHeight() != dst.getHeight()){ + throw new IllegalArgumentException( + "Source and destination images do not have " + + "the same height!"); + } + + if (!srcCM.equals(dst.getColorModel())) { + // Treat BufferedImage.TYPE_INT_RGB and + // BufferedImage.TYPE_INT_ARGB as same + if (!((src.getType() == BufferedImage.TYPE_INT_RGB || src + .getType() == BufferedImage.TYPE_INT_ARGB) && (dst + .getType() == BufferedImage.TYPE_INT_RGB || dst + .getType() == BufferedImage.TYPE_INT_ARGB))) { + finalDst = dst; + dst = createCompatibleDestImage(src, null); + } + } } // XXX - todo